public static void AddNewCatout(Point3d StartPoint, Point3d EndPoint, ObjectId GroupOI) { double MyScale = Atend.Base.Design.DProductProperties.AccessSelectBySoftwareCode((int)Atend.Control.Enum.ProductType.CatOut).Scale; DrawCatOutJig _DrawCatOutJig = new DrawCatOutJig(MyScale); Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; ObjectIdCollection OIC = new ObjectIdCollection(); foreach (Entity ent in _DrawCatOutJig.GetDemoForEdit(StartPoint, EndPoint)) { 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); }
public void DrawCatout() { Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; System.Data.DataTable ParentList = Atend.Global.Acad.UAcad.DetermineParent((int)Atend.Control.Enum.ProductType.CatOut); double V1 = 0; double V2 = 0; double MyScale = Atend.Base.Design.DProductProperties.AccessSelectBySoftwareCode((int)Atend.Control.Enum.ProductType.CatOut).Scale; double MyCommentScale = Atend.Base.Design.DProductProperties.AccessSelectBySoftwareCode((int)Atend.Control.Enum.ProductType.CatOut).CommentScale; try { 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) { //ed.WriteMessage("Voltage was same \n"); DrawCatOutJig _DrawBreakerJig = new DrawCatOutJig(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))); //ed.WriteMessage("COUNT OF ENTITY :{0}\n",ents.Count); if (SaveCatOutData()) { //ed.WriteMessage("data saved {0} \n",ents.Count); 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()); //ed.WriteMessage("111 \n"); Atend.Global.Acad.AcadJigs.MyLine terminal = ent as Atend.Global.Acad.AcadJigs.MyLine; //ed.WriteMessage("112 \n"); object ProductType = null; //ed.WriteMessage("changed \n"); if (terminal != null) { if (terminal.AdditionalDictionary.TryGetValue("ProductType", out ProductType)) { //ed.WriteMessage("113 \n"); 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); //ed.WriteMessage("entity added \n"); if (TerminalOI == ObjectId.Null) { if (KetOI == ObjectId.Null) { //ed.WriteMessage("KEYOI == null\n"); Atend.Base.Acad.AT_INFO groupInfo = new Atend.Base.Acad.AT_INFO(NOI); groupInfo.NodeCode = CatOutPack.Code.ToString(); groupInfo.ParentCode = ""; groupInfo.NodeType = (int)Atend.Control.Enum.ProductType.CatOut; groupInfo.ProductCode = CatOutPack.ProductCode; groupInfo.Insert(); } else { //ed.WriteMessage("KEYOI != null\n"); Atend.Base.Acad.AT_INFO groupInfo = new Atend.Base.Acad.AT_INFO(NOI); groupInfo.NodeCode = CatOutPack.Code.ToString(); groupInfo.ParentCode = ""; groupInfo.NodeType = (int)Atend.Control.Enum.ProductType.Key; groupInfo.ProductCode = CatOutPack.ProductCode; groupInfo.Insert(); } } else { //ed.WriteMessage("terminal != null\n"); Atend.Base.Acad.AT_INFO groupInfo = new Atend.Base.Acad.AT_INFO(NOI); groupInfo.NodeCode = CatOutPack.Code.ToString(); groupInfo.ParentCode = ""; groupInfo.NodeType = (int)Atend.Control.Enum.ProductType.Terminal; groupInfo.ProductCode = CatOutPack.ProductCode; groupInfo.Insert(); } } ObjectId GOI = Atend.Global.Acad.Global.MakeGroup(CatOutPack.Code.ToString(), OIC); //ed.WriteMessage("----<<<<<----GOI:{0}\n", GOI); Atend.Base.Acad.AT_INFO groupInfo1 = new Atend.Base.Acad.AT_INFO(GOI); groupInfo1.NodeCode = CatOutPack.Code.ToString(); groupInfo1.ParentCode = ""; groupInfo1.NodeType = (int)Atend.Control.Enum.ProductType.CatOut; groupInfo1.ProductCode = CatOutPack.ProductCode; groupInfo1.Insert(); ObjectId TextOi = Atend.Global.Acad.UAcad.DrawEntityOnScreen(Atend.Global.Acad.UAcad.WriteNote(ECatOut.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 = CatOutPack.Code.ToString(); textInfo.NodeType = (int)Atend.Control.Enum.ProductType.Comment; textInfo.ProductCode = 0; textInfo.Insert(); //ed.WriteMessage("text info inserted \n"); 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(); //ed.WriteMessage("group info inserted \n"); Atend.Base.Acad.AT_SUB.AddToAT_SUB(GOI, per.ObjectId); Atend.Base.Acad.AT_SUB.AddToAT_SUB(GOI, per1.ObjectId); //ed.WriteMessage("other nodes info inserted \n"); } } 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 ) } catch (System.Exception ex) { ed.WriteMessage("DRAW ING FAILED :{0} \n", ex.Message); } }