Пример #1
0
        public static void AddNewBreaker(Point3d StartPoint, Point3d EndPoint, ObjectId GroupOI)
        {
            double MyScale = Atend.Base.Design.DProductProperties.AccessSelectBySoftwareCode((int)Atend.Control.Enum.ProductType.Breaker).Scale;

            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
            //ed.WriteMessage("start22:{0} end22:{1} \n", StartPoint, EndPoint);
            DrawBreakerJig     _DrawBreakerJig = new DrawBreakerJig(MyScale);
            ObjectIdCollection OIC             = new ObjectIdCollection();

            foreach (Entity ent in _DrawBreakerJig.GetDemoForEdit(StartPoint, EndPoint))
            {
                //ed.WriteMessage("each entity \n");
                ObjectId NewOI = Atend.Global.Acad.UAcad.DrawEntityOnScreen(ent, Atend.Control.Enum.AutoCadLayerName.GENERAL.ToString());
                OIC.Add(NewOI);
                Atend.Base.Acad.AT_INFO _AT_INFO = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(GroupOI);
                _AT_INFO.SelectedObjectId = NewOI;
                _AT_INFO.Insert();


                //Atend.Global.Acad.UAcad.DrawEntityOnScreen(ent, Atend.Control.Enum.AutoCadLayerName.GENERAL.ToString());
            }
            //ed.WriteMessage("add to group \n");
            Atend.Global.Acad.Global.AddObjectToGroup(GroupOI, OIC);
        }
Пример #2
0
        //update in tehran 7/15
        public void DrawBreaker()
        {
            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;

            //ed.WriteMessage("DRaw BREAKER \n");
            System.Data.DataTable ParentList = Atend.Global.Acad.UAcad.DetermineParent((int)Atend.Control.Enum.ProductType.Breaker);
            double V1 = 0;
            double V2 = 0;

            double MyScale        = Atend.Base.Design.DProductProperties.AccessSelectBySoftwareCode((int)Atend.Control.Enum.ProductType.Breaker).Scale;
            double MyCommentScale = Atend.Base.Design.DProductProperties.AccessSelectBySoftwareCode((int)Atend.Control.Enum.ProductType.Breaker).CommentScale;

            PromptEntityOptions peo1 = new PromptEntityOptions("Select first node:");
            PromptEntityResult  per  = ed.GetEntity(peo1);

            if (per.Status == PromptStatus.OK)
            {
                Atend.Base.Acad.AT_INFO Info1 = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(per.ObjectId);
                DataRow[] drs = ParentList.Select(string.Format("SoftwareCode={0}", Info1.NodeType));
                if (drs.Length != 0)
                {
                    switch (((Atend.Control.Enum.ProductType)drs[0]["SoftwareCode"]))
                    {
                    case Atend.Control.Enum.ProductType.HeaderCabel:
                        //V1 = Atend.Base.Equipment.EHeaderCabel.AccessSelectByCode(Info1.ProductCode);
                        V1 = 0;
                        break;

                    case Atend.Control.Enum.ProductType.Consol:
                        V1 = Atend.Base.Equipment.EConsol.AccessSelectByCode(Info1.ProductCode).VoltageLevel;
                        break;

                    case Atend.Control.Enum.ProductType.KablSho:
                        //V1 = Atend.Base.Equipment.EKablsho.AccessSelectByCode(Info1.ProductCode);
                        V1 = 0;
                        break;

                    case Atend.Control.Enum.ProductType.Kalamp:
                        V1 = Atend.Base.Equipment.EClamp.AccessSelectByCode(Info1.ProductCode).VoltageLevel;
                        break;
                    }
                    PromptEntityOptions peo2 = new PromptEntityOptions("Select second node:");
                    PromptEntityResult  per1 = ed.GetEntity(peo2);
                    if (per1.Status == PromptStatus.OK)
                    {
                        Atend.Base.Acad.AT_INFO Info2 = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(per1.ObjectId);
                        DataRow[] drs1 = ParentList.Select(string.Format("SoftwareCode={0}", Info2.NodeType));
                        if (drs1.Length != 0)
                        {
                            switch (((Atend.Control.Enum.ProductType)drs1[0]["SoftwareCode"]))
                            {
                            case Atend.Control.Enum.ProductType.HeaderCabel:
                                //V1 = Atend.Base.Equipment.EHeaderCabel.AccessSelectByCode(Info1.ProductCode);
                                V2 = 0;
                                break;

                            case Atend.Control.Enum.ProductType.Consol:
                                V2 = Atend.Base.Equipment.EConsol.AccessSelectByCode(Info2.ProductCode).VoltageLevel;
                                break;

                            case Atend.Control.Enum.ProductType.KablSho:
                                //V1 = Atend.Base.Equipment.EKablsho.AccessSelectByCode(Info1.ProductCode);
                                V2 = 0;
                                break;

                            case Atend.Control.Enum.ProductType.Kalamp:
                                V2 = Atend.Base.Equipment.EClamp.AccessSelectByCode(Info2.ProductCode).VoltageLevel;
                                break;
                            }

                            if (V1 == V2 && Info1.ParentCode == Info2.ParentCode)
                            {
                                DrawBreakerJig _DrawBreakerJig = new DrawBreakerJig(MyScale);
                                List <Entity>  ents            = _DrawBreakerJig.GetDemo(
                                    Atend.Global.Acad.UAcad.CenterOfEntity(Atend.Global.Acad.UAcad.GetEntityByObjectID(per.ObjectId)),
                                    Atend.Global.Acad.UAcad.CenterOfEntity(Atend.Global.Acad.UAcad.GetEntityByObjectID(per1.ObjectId)));

                                if (SaveBreakerData())
                                {
                                    ObjectIdCollection OIC = new ObjectIdCollection();
                                    foreach (Entity ent in ents)
                                    {
                                        ObjectId TerminalOI = ObjectId.Null;
                                        ObjectId KetOI      = ObjectId.Null;
                                        ObjectId NOI        = Atend.Global.Acad.UAcad.DrawEntityOnScreen(ent, Atend.Control.Enum.AutoCadLayerName.GENERAL.ToString());
                                        Atend.Global.Acad.AcadJigs.MyLine terminal = ent as Atend.Global.Acad.AcadJigs.MyLine;
                                        if (terminal != null)
                                        {
                                            object ProductType = null;
                                            if (terminal.AdditionalDictionary.TryGetValue("ProductType", out ProductType))
                                            {
                                                if (Convert.ToInt32(ProductType) == (int)Atend.Control.Enum.ProductType.Terminal)
                                                {
                                                    //ed.WriteMessage("terminal aws found\n");
                                                    if (ProductType != null)
                                                    {
                                                        TerminalOI = NOI;
                                                    }
                                                }
                                                else if (Convert.ToInt32(ProductType) == (int)Atend.Control.Enum.ProductType.Key)
                                                {
                                                    //ed.WriteMessage("Key aws found\n");
                                                    if (ProductType != null)
                                                    {
                                                        KetOI = NOI;
                                                    }
                                                }
                                            }
                                        }
                                        OIC.Add(NOI);



                                        if (TerminalOI == ObjectId.Null)
                                        {
                                            if (KetOI == ObjectId.Null)
                                            {
                                                Atend.Base.Acad.AT_INFO groupInfo = new Atend.Base.Acad.AT_INFO(NOI);
                                                groupInfo.NodeCode    = BreakerPack.Code.ToString();
                                                groupInfo.ParentCode  = "";
                                                groupInfo.NodeType    = (int)Atend.Control.Enum.ProductType.Breaker;
                                                groupInfo.ProductCode = BreakerPack.ProductCode;
                                                groupInfo.Insert();
                                            }
                                            else
                                            {
                                                //ed.WriteMessage("KEYOI != null\n");
                                                Atend.Base.Acad.AT_INFO groupInfo = new Atend.Base.Acad.AT_INFO(NOI);
                                                groupInfo.NodeCode    = BreakerPack.Code.ToString();
                                                groupInfo.ParentCode  = "";
                                                groupInfo.NodeType    = (int)Atend.Control.Enum.ProductType.Key;
                                                groupInfo.ProductCode = BreakerPack.ProductCode;
                                                groupInfo.Insert();
                                            }
                                        }
                                        else
                                        {
                                            Atend.Base.Acad.AT_INFO groupInfo = new Atend.Base.Acad.AT_INFO(NOI);
                                            groupInfo.NodeCode    = BreakerPack.Code.ToString();
                                            groupInfo.ParentCode  = "";
                                            groupInfo.NodeType    = (int)Atend.Control.Enum.ProductType.Terminal;
                                            groupInfo.ProductCode = BreakerPack.ProductCode;
                                            groupInfo.Insert();
                                        }
                                    }

                                    ObjectId GOI = Atend.Global.Acad.Global.MakeGroup(BreakerPack.Code.ToString(), OIC);
                                    //ed.WriteMessage("----<<<<<----GOI:{0}\n",GOI);

                                    Atend.Base.Acad.AT_INFO groupInfo1 = new Atend.Base.Acad.AT_INFO(GOI);
                                    groupInfo1.NodeCode    = BreakerPack.Code.ToString();
                                    groupInfo1.ParentCode  = "";
                                    groupInfo1.NodeType    = (int)Atend.Control.Enum.ProductType.Breaker;
                                    groupInfo1.ProductCode = BreakerPack.ProductCode;
                                    groupInfo1.Insert();


                                    ObjectId TextOi = Atend.Global.Acad.UAcad.DrawEntityOnScreen(
                                        Atend.Global.Acad.UAcad.WriteNote(eBreaker.Comment,
                                                                          _DrawBreakerJig.MyCenterPoint
                                                                          , MyCommentScale), Atend.Control.Enum.AutoCadLayerName.GENERAL.ToString()
                                        );

                                    Atend.Base.Acad.AT_INFO textInfo = new Atend.Base.Acad.AT_INFO(TextOi);
                                    textInfo.NodeCode    = "";
                                    textInfo.ParentCode  = BreakerPack.Code.ToString();
                                    textInfo.NodeType    = (int)Atend.Control.Enum.ProductType.Comment;
                                    textInfo.ProductCode = 0;
                                    textInfo.Insert();

                                    Atend.Base.Acad.AT_SUB groupSub = new Atend.Base.Acad.AT_SUB(GOI);
                                    groupSub.SubIdCollection.Add(per.ObjectId);
                                    groupSub.SubIdCollection.Add(per1.ObjectId);
                                    groupSub.SubIdCollection.Add(TextOi);
                                    groupSub.Insert();

                                    Atend.Base.Acad.AT_SUB.AddToAT_SUB(GOI, per.ObjectId);
                                    Atend.Base.Acad.AT_SUB.AddToAT_SUB(GOI, per1.ObjectId);
                                }
                                //Line l = new Line(
                                //    Atend.Global.Acad.UAcad.CenterOfEntity(Atend.Global.Acad.UAcad.GetEntityByObjectID(per.ObjectId)),
                                //    Atend.Global.Acad.UAcad.CenterOfEntity(Atend.Global.Acad.UAcad.GetEntityByObjectID(per1.ObjectId)));
                                //Atend.Global.Acad.UAcad.DrawEntityOnScreen(l);
                            }
                            else
                            {
                                ed.WriteMessage("Voltage was not ok \n");
                            }
                        } //if (drs1.Length != 0)
                    }     //if (per1.Status == PromptStatus.OK)
                }         //if (drs.Length != 0)
            }             //if (per.Status == PromptStatus.OK )
        }