Ejemplo n.º 1
0
        public static void AddNewDisconnector(Point3d StartPoint, Point3d EndPoint, ObjectId GroupOI)
        {
            double MyScale = Atend.Base.Design.DProductProperties.AccessSelectBySoftwareCode((int)Atend.Control.Enum.ProductType.Disconnector).Scale;
            //Database db = Application.DocumentManager.MdiActiveDocument.Database;
            DrawDisconnectorJig _DrawDisconnectorJig = new DrawDisconnectorJig(MyScale);
            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
            //ed.WriteMessage("start22:{0} end22:{1} \n", StartPoint, EndPoint);
            ObjectIdCollection OIC = new ObjectIdCollection();

            foreach (Entity ent in _DrawDisconnectorJig.GetDemoForEdit(StartPoint, EndPoint))
            {
                //Group group = tr.GetObject(GroupOI, OpenMode.ForWrite, true) as Group;
                //if (group != null)
                //{
                //ObjectId[] objs = group.GetAllEntityIds();
                //foreach (ObjectId id in objs)
                //{

                //    OIC.Add(id);

                //}
                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.Global.AddObjectToGroup(GroupOI, OIC);
            //ed.WriteMessage("add to group for new drawing finished\n");
            //}
            //}
        }
Ejemplo n.º 2
0
        //update in tehran 7/15
        public void DrawDisconnector()
        {
            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;

            System.Data.DataTable ParentList = Atend.Global.Acad.UAcad.DetermineParent((int)Atend.Control.Enum.ProductType.Disconnector);

            double MyScale        = Atend.Base.Design.DProductProperties.AccessSelectBySoftwareCode((int)Atend.Control.Enum.ProductType.Disconnector).Scale;
            double MyCommentScale = Atend.Base.Design.DProductProperties.AccessSelectBySoftwareCode((int)Atend.Control.Enum.ProductType.Disconnector).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)
                {
                    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 && Info1.ParentCode == Info2.ParentCode)
                        {
                            DrawDisconnectorJig _DrawDisconnectorJig = new DrawDisconnectorJig(MyScale);
                            List <Entity>       ents = _DrawDisconnectorJig.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 (SaveDisConnectorData())
                            {
                                ObjectIdCollection OIC = new ObjectIdCollection();
                                //ed.WriteMessage("go for each\n");
                                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)
                                        {
                                            //ed.WriteMessage("TerminalOI == null\n");
                                            Atend.Base.Acad.AT_INFO groupInfo = new Atend.Base.Acad.AT_INFO(NOI);
                                            groupInfo.NodeCode    = DisConnectorPack.Code.ToString();
                                            groupInfo.ParentCode  = "";
                                            groupInfo.NodeType    = (int)Atend.Control.Enum.ProductType.Disconnector;
                                            groupInfo.ProductCode = DisConnectorPack.ProductCode;
                                            groupInfo.Insert();
                                        }
                                        else
                                        {
                                            //ed.WriteMessage("KEYOI != null\n");
                                            Atend.Base.Acad.AT_INFO groupInfo = new Atend.Base.Acad.AT_INFO(NOI);
                                            groupInfo.NodeCode    = DisConnectorPack.Code.ToString();
                                            groupInfo.ParentCode  = "";
                                            groupInfo.NodeType    = (int)Atend.Control.Enum.ProductType.Key;
                                            groupInfo.ProductCode = DisConnectorPack.ProductCode;
                                            groupInfo.Insert();
                                        }
                                    }
                                    else
                                    {
                                        //ed.WriteMessage("TerminalOI != null\n");
                                        Atend.Base.Acad.AT_INFO groupInfo = new Atend.Base.Acad.AT_INFO(NOI);
                                        groupInfo.NodeCode    = DisConnectorPack.Code.ToString();
                                        groupInfo.ParentCode  = "";
                                        groupInfo.NodeType    = (int)Atend.Control.Enum.ProductType.Terminal;
                                        groupInfo.ProductCode = DisConnectorPack.ProductCode;
                                        groupInfo.Insert();
                                    }
                                }

                                ObjectId GOI = Atend.Global.Acad.Global.MakeGroup(DisConnectorPack.Code.ToString(), OIC);

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


                                ObjectId TextOi = Atend.Global.Acad.UAcad.DrawEntityOnScreen(
                                    Atend.Global.Acad.UAcad.WriteNote(eDisConnector.Comment,
                                                                      _DrawDisconnectorJig.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  = DisConnectorPack.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);
                            }
                        } //if (drs1.Length != 0)
                    }     //if (per1.Status == PromptStatus.OK)
                }         //if (drs.Length != 0)
            }             //if (per.Status == PromptStatus.OK )
        }