public void ChangeComment(ObjectId SelectedLineObjectID, string Text) { Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; using (DocumentLock dl = Application.DocumentManager.MdiActiveDocument.LockDocument()) { Atend.Base.Acad.AT_SUB at_sub = Atend.Base.Acad.AT_SUB.SelectBySelectedObjectId(SelectedLineObjectID); Atend.Base.Acad.AT_INFO at_info; if (at_sub.SubIdCollection.Count > 0) { foreach (ObjectId oi in at_sub.SubIdCollection) { at_info = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(oi); if (at_info.ParentCode.Equals("NONE")) { } else if (at_info.NodeType == (int)Atend.Control.Enum.ProductType.Comment) { ChangeEntityText(oi, Text); } } } else { } } }
private double GetStartPoleAngle() { double Angle = 0; Atend.Base.Acad.AT_SUB BranchSub = Atend.Base.Acad.AT_SUB.SelectBySelectedObjectId(BranchEntity.ObjectId); foreach (ObjectId oi in BranchSub.SubIdCollection) { Atend.Base.Acad.AT_INFO SubInfo = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(oi); if (SubInfo.NodeType == (int)Atend.Control.Enum.ProductType.Consol || SubInfo.NodeType == (int)Atend.Control.Enum.ProductType.Kalamp) { Atend.Base.Acad.AT_SUB ConsolSub = Atend.Base.Acad.AT_SUB.SelectBySelectedObjectId(oi); foreach (ObjectId oii in ConsolSub.SubIdCollection) { Atend.Base.Acad.AT_INFO poleInfo = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(oii); if (poleInfo.NodeType == (int)Atend.Control.Enum.ProductType.Pole) { Angle = poleInfo.Angle; } else if (poleInfo.NodeType == (int)Atend.Control.Enum.ProductType.PoleTip) { Angle = poleInfo.Angle; } } } } return(Angle); }
private ObjectId GetEndConsolOrClamp() { Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; ObjectId FoundOne = ObjectId.Null; Atend.Base.Acad.AT_SUB BranchSub = Atend.Base.Acad.AT_SUB.SelectBySelectedObjectId(BranchEntity.ObjectId); foreach (ObjectId oi in BranchSub.SubIdCollection) { Atend.Base.Acad.AT_INFO SubInfo = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(oi); if (SubInfo.NodeType == (int)Atend.Control.Enum.ProductType.Consol) { if (Atend.Global.Acad.UAcad.CenterOfEntity(Atend.Global.Acad.UAcad.GetEntityByObjectID(oi)) == branchEntity.EndPoint) { FoundOne = oi; } } else if (SubInfo.NodeType == (int)Atend.Control.Enum.ProductType.Kalamp) { if (Atend.Global.Acad.UAcad.CenterOfEntity(Atend.Global.Acad.UAcad.GetEntityByObjectID(oi)) == branchEntity.EndPoint) { FoundOne = oi; } } } ed.WriteMessage("End node: {0} \n", FoundOne); return(FoundOne); }
public static ObjectId DrawConnectionPoint(Point3d CenterPoint, ObjectId ParentOI) { Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; DrawConnectionPointJig DCP = new DrawConnectionPointJig(); Entity ent = DCP.GetDemo(CenterPoint); ObjectId ConnectionOI = ObjectId.Null; if (ent != null) { ConnectionOI = Atend.Global.Acad.UAcad.DrawEntityOnScreen(ent, Atend.Control.Enum.AutoCadLayerName.GENERAL.ToString()); Atend.Base.Acad.AT_INFO ParentInfo = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(ParentOI); Atend.Base.Acad.AT_INFO at_info = new Atend.Base.Acad.AT_INFO(ConnectionOI); //ed.WriteMessage("ParentCode For connection Point: {0}\n", ParentInfo.NodeCode); at_info.ParentCode = ParentInfo.NodeCode; at_info.NodeCode = ""; at_info.NodeType = (int)Atend.Control.Enum.ProductType.ConnectionPoint; at_info.ProductCode = 0; at_info.Insert(); Atend.Base.Acad.AT_SUB ConnectionPSub = new Atend.Base.Acad.AT_SUB(ConnectionOI); ConnectionPSub.SubIdCollection.Add(ParentOI); ConnectionPSub.Insert(); Atend.Base.Acad.AT_SUB.AddToAT_SUB(ConnectionOI, ParentOI); } return(ConnectionOI); }
public static bool DeleteLight(ObjectId LightOI) { Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; try { ObjectId id = Atend.Global.Acad.UAcad.GetEntityGroup(LightOI); //Find Parent Atend.Base.Acad.AT_SUB EntitySb = Atend.Base.Acad.AT_SUB.SelectBySelectedObjectId(id); foreach (ObjectId oi in EntitySb.SubIdCollection) { Atend.Base.Acad.AT_INFO pInfo = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(oi); if (pInfo.ParentCode != "NONE" && (pInfo.NodeType == (int)Atend.Control.Enum.ProductType.Pole || pInfo.NodeType == (int)Atend.Control.Enum.ProductType.PoleTip)) { Atend.Base.Acad.AT_SUB pSub = Atend.Base.Acad.AT_SUB.SelectBySelectedObjectId(oi); foreach (ObjectId soi in pSub.SubIdCollection) { Atend.Base.Acad.AT_INFO Info1 = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(soi); if (Info1.ParentCode != "NONE" && Info1.NodeType == (int)Atend.Control.Enum.ProductType.Light && id == soi) { Atend.Base.Acad.AT_SUB.RemoveFromAT_SUB(id, oi); } } } if (pInfo.ParentCode != "NONE" && pInfo.NodeType == (int)Atend.Control.Enum.ProductType.Comment) { if (!Atend.Global.Acad.AcadRemove.DeleteEntityByObjectId(oi)) { throw new System.Exception("Error In Delete Comment\n"); } } } //Delete Group ObjectIdCollection Collection = Atend.Global.Acad.UAcad.GetGroupSubEntities(id); foreach (ObjectId collect in Collection) { if (!Atend.Global.Acad.AcadRemove.DeleteEntityByObjectId(collect)) { throw new System.Exception("Error In Delete Group\n"); } } //+++ if (!Atend.Global.Acad.AcadRemove.DeleteEntityByObjectId(LightOI)) { throw new System.Exception("GRA while delete StreetBox\n"); } } catch (System.Exception ex) { ed.WriteMessage("GRA ERROR Light: {0} \n", ex.Message); return(false); } return(true); }
public static bool DeleteMeasuredJackPanelData(ObjectId MeasuredJackPanelOI) { Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; try { ObjectId id = Atend.Global.Acad.UAcad.GetEntityGroup(MeasuredJackPanelOI); ObjectIdCollection Collection = Atend.Global.Acad.UAcad.GetGroupSubEntities(id); foreach (ObjectId sub in Collection) { Atend.Base.Acad.AT_SUB EntityS = Atend.Base.Acad.AT_SUB.SelectBySelectedObjectId(sub); foreach (ObjectId oisub in EntityS.SubIdCollection) { Atend.Base.Acad.AT_INFO atinfo = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(oisub); if (atinfo.ParentCode != "NONE" && atinfo.NodeType == (int)Atend.Control.Enum.ProductType.HeaderCabel) { Atend.Base.Acad.AT_SUB Sub = Atend.Base.Acad.AT_SUB.SelectBySelectedObjectId(oisub); foreach (ObjectId oi in Sub.SubIdCollection) { Atend.Base.Acad.AT_INFO atinfo2 = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(oi); if (atinfo2.ParentCode != "NONE" && atinfo2.NodeType == (int)Atend.Control.Enum.ProductType.GroundCabel) { if (!Atend.Base.Design.DBranch.AccessDelete(new Guid(atinfo2.NodeCode.ToString()))) { throw new System.Exception("Error In Delete dbranch\n"); } } } if (!Atend.Base.Design.DPackage.AccessDelete(new Guid(atinfo.NodeCode.ToString()))) { throw new System.Exception("Error In Delete dpackage_headercabel\n"); } } } } //delete MeasuredJackPanel Atend.Base.Acad.AT_INFO conductorinfo = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(MeasuredJackPanelOI); if (!Atend.Base.Design.DPackage.AccessDelete(new Guid(conductorinfo.NodeCode.ToString()))) { throw new System.Exception("Error In Delete dpackage_measure\n"); } } catch (System.Exception ex) { ed.WriteMessage("Data ERROR MeasuredJackPanel : {0} \n", ex.Message); return(false); } return(true); }
public static bool DeleteKablshoData(ObjectId KablshoOI, OleDbTransaction _Transaction, OleDbConnection _Connection) { Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; try { Atend.Base.Acad.AT_SUB SubGP = Atend.Base.Acad.AT_SUB.SelectBySelectedObjectId(KablshoOI); foreach (ObjectId oi in SubGP.SubIdCollection) { Atend.Base.Acad.AT_INFO atinfo = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(oi); if (atinfo.ParentCode != "NONE" && atinfo.NodeType == (int)Atend.Control.Enum.ProductType.GroundCabel) { if (!Atend.Base.Design.DBranch.AccessDelete(new Guid(atinfo.NodeCode.ToString()), _Transaction, _Connection)) { throw new System.Exception("Error In Delete dbranch\n"); } } if (atinfo.ParentCode != "NONE" && (atinfo.NodeType == (int)Atend.Control.Enum.ProductType.Breaker || atinfo.NodeType == (int)Atend.Control.Enum.ProductType.Disconnector || atinfo.NodeType == (int)Atend.Control.Enum.ProductType.CatOut)) { if (!Atend.Base.Design.DPackage.AccessDelete(new Guid(atinfo.NodeCode.ToString()), _Transaction, _Connection)) { throw new System.Exception("Error In Delete DPackage\n"); } } if (atinfo.ParentCode != "NONE" && atinfo.NodeType == (int)Atend.Control.Enum.ProductType.Terminal) { if (!Atend.Base.Design.DBranch.AccessDelete(new Guid(atinfo.NodeCode.ToString()), _Transaction, _Connection)) { throw new System.Exception("Error In Delete dbranch\n"); } } } Atend.Base.Acad.AT_INFO Kablshoinfo = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(KablshoOI); if (!Atend.Base.Design.DPackage.AccessDelete(new Guid(Kablshoinfo.NodeCode.ToString()), _Transaction, _Connection)) { throw new System.Exception("Error In Delete DPackage\n"); } } catch (System.Exception ex) { ed.WriteMessage("GRA ERROR Kablsho : {0} \n", ex.Message); _Transaction.Rollback(); return(false); } return(true); }
public static bool DeleteGroundPost(ObjectId GroundPostOI) { Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; bool AllObjectsDeleted = true; Atend.Base.Acad.AT_SUB GroundPostSub = Atend.Base.Acad.AT_SUB.SelectBySelectedObjectId(GroundPostOI); try { foreach (ObjectId oi in GroundPostSub.SubIdCollection) { ObjectIdCollection GroupSubs = Atend.Global.Acad.UAcad.GetGroupSubEntities(oi); if (GroupSubs.Count != 0) { foreach (ObjectId oii in GroupSubs) { if (!DeleteEntityByObjectId(oii)) { AllObjectsDeleted = false; } } if (!DeleteEntityByObjectId(oi)) { AllObjectsDeleted = false; } } else { if (!DeleteEntityByObjectId(oi)) { AllObjectsDeleted = false; } } } if (!DeleteEntityByObjectId(GroundPostOI)) { AllObjectsDeleted = false; } } catch (System.Exception ex) { ed.WriteMessage("Error GroundPost Graphical Delete:{0}\n", ex.Message); } return(AllObjectsDeleted); }
public static bool DeleteJumper(ObjectId jumper) { Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; try { Atend.Base.Acad.AT_SUB jumperSub = Atend.Base.Acad.AT_SUB.SelectBySelectedObjectId(jumper); foreach (ObjectId jumperSubOI in jumperSub.SubIdCollection) { Atend.Base.Acad.AT_INFO SubInfo = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(jumperSubOI); if (SubInfo.ParentCode != "NONE" && SubInfo.NodeType == (int)Atend.Control.Enum.ProductType.Conductor) { Atend.Base.Acad.AT_SUB conductorSub = Atend.Base.Acad.AT_SUB.SelectBySelectedObjectId(jumperSubOI); foreach (ObjectId oi in conductorSub.SubIdCollection) { Atend.Base.Acad.AT_INFO at_info = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(oi); if (at_info.ParentCode != "NONE" && at_info.NodeType == (int)Atend.Control.Enum.ProductType.Jumper && at_info.SelectedObjectId == jumper) { Atend.Base.Acad.AT_SUB.RemoveFromAT_SUB(oi, jumperSubOI); } } } } //+++ if (!Atend.Global.Acad.AcadRemove.DeleteEntityByObjectId(jumper)) { throw new System.Exception("GRA while delete conductor \n"); } } catch (System.Exception ex) { ed.WriteMessage("GRA ERROR JUMPER : {0} \n", ex.Message); return(false); } return(true); }
public void DrawGround02() { Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; bool conti = true; //ed.WriteMessage("1\n"); List <Entity> Entities; //ed.WriteMessage("2\n"); double MyScale = Atend.Base.Design.DProductProperties.AccessSelectBySoftwareCode((int)Atend.Control.Enum.ProductType.Ground).Scale; //ed.WriteMessage("3\n"); //double MyCommentScale = Atend.Base.Design.DProductProperties.AccessSelectBySoftwareCode((int)Atend.Control.Enum.ProductType.Ground).CommentScale; DrawGroundJig02 _DrawGroundJig = new DrawGroundJig02(MyScale); while (conti) { //PromptEntityOptions PEO = new PromptEntityOptions("Select Parent:"); //PromptEntityResult PER = ed.GetEntity(PEO); //if (PER.Status == PromptStatus.OK) //{ //Atend.Base.Acad.AT_INFO SelectedEntityInfo = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(PER.ObjectId); //if (SelectedEntityInfo.ParentCode != "NONE") //{ //System.Data.DataTable Parents = Atend.Global.Acad.UAcad.DetermineParent((int)Atend.Control.Enum.ProductType.Ground); //DataRow[] drs = Parents.Select(string.Format("SoftwareCode={0}", SelectedEntityInfo.NodeType)); //if (drs.Length > 0) //{ ObjectId ParentOI = ObjectId.Null; while (conti) { _DrawGroundJig.GetStartPoint = true; _DrawGroundJig.GetEndPoint = false; PromptResult pr = ed.Drag(_DrawGroundJig); //pr = ed.Drag(_DrawGroundJig); if (pr.Status == PromptStatus.OK) { if (IsValidParent(_DrawGroundJig.StartPoint, out ParentOI)) { _DrawGroundJig.GetStartPoint = false; _DrawGroundJig.GetEndPoint = true; pr = ed.Drag(_DrawGroundJig); //pr = ed.Drag(_DrawGroundJig); if (pr.Status == PromptStatus.OK) { _DrawGroundJig.GetStartPoint = false; _DrawGroundJig.GetEndPoint = false; conti = false; Entities = _DrawGroundJig.GetEntities(); //foreach (Entity en in Entities) //{ // Atend.Global.Acad.UAcad.DrawEntityOnScreen(en, Atend.Control.Enum.AutoCadLayerName.GENERAL.ToString()); //} #region SaveData ObjectIdCollection OIC = new ObjectIdCollection(); Atend.Base.Acad.AT_INFO SelectedEntityInfo = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(ParentOI); if (SaveGroundData(SelectedEntityInfo.NodeCode)) { foreach (Entity ent in Entities) { OIC.Add(Atend.Global.Acad.UAcad.DrawEntityOnScreen(ent, Atend.Control.Enum.AutoCadLayerName.GENERAL.ToString())); Atend.Base.Acad.AT_INFO GroundInfo = new Atend.Base.Acad.AT_INFO(OIC[OIC.Count - 1]); GroundInfo.ParentCode = SelectedEntityInfo.NodeCode; GroundInfo.NodeCode = GroundPack.Code.ToString(); GroundInfo.NodeType = (int)Atend.Control.Enum.ProductType.Ground; GroundInfo.ProductCode = eGround.Code; GroundInfo.Insert(); } ObjectId GOI = Atend.Global.Acad.Global.MakeGroup(GroundPack.Code.ToString(), OIC); Atend.Base.Acad.AT_INFO GroundGroupInfo = new Atend.Base.Acad.AT_INFO(GOI); GroundGroupInfo.ParentCode = SelectedEntityInfo.NodeCode; GroundGroupInfo.NodeCode = GroundPack.Code.ToString(); GroundGroupInfo.NodeType = (int)Atend.Control.Enum.ProductType.Ground; GroundGroupInfo.ProductCode = eGround.Code; GroundGroupInfo.Insert(); Atend.Base.Acad.AT_SUB.AddToAT_SUB(GOI, ParentOI); Atend.Base.Acad.AT_SUB GroundSub = new Atend.Base.Acad.AT_SUB(GOI); GroundSub.SubIdCollection.Add(ParentOI); GroundSub.Insert(); } #endregion } else { conti = false; } conti = false; } } else { ed.WriteMessage("parent was not valid\n"); conti = false; } }// end while //} //else //{ // string s = ""; // foreach (DataRow dr in Parents.Rows) // { // s = s + Atend.Base.Design.DProductProperties.AccessSelectByCodeDrawable(Convert.ToInt32(dr["ContainerCode"])).ProductName + "-"; // } // Atend.Global.Acad.Notification notification = new Atend.Global.Acad.Notification(); // notification.Title = "ÇÊÕÇáÇÊ ãÌÇÒ"; // notification.Msg = s; // notification.infoCenterBalloon(); //} //} //} //else //{ // conti = false; //} } }
private void btnSelect_Click(object sender, EventArgs e) { Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; Guid StartPoleCode = Guid.Empty; Autodesk.AutoCAD.DatabaseServices.ObjectId _BranchOi = Autodesk.AutoCAD.DatabaseServices.ObjectId.Null; int _vol = 0; //gClamp.Visible = false; //gConsol.Visible = false; BranchesData.Clear(); this.Hide(); PromptSelectionOptions pso = new PromptSelectionOptions(); pso.MessageForAdding = "Select Branches Please"; //PromptEntityOptions PEO = new PromptEntityOptions(": \n"); //PromptEntityResult PER = ed.GetEntity(PEO); PromptSelectionResult PSR = ed.GetSelection(pso); SelectdEntities.Clear(); if (PSR.Status == PromptStatus.OK) { SelectionSet ss = PSR.Value; ////////if (ss.Count > 0) ////////{ //////// Atend.Base.Acad.AT_INFO SelectedBranchInfo = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(ss[0].ObjectId); //////// if (SelectedBranchInfo.NodeType == (int)Atend.Control.Enum.ProductType.Conductor) //////// { //////// IsConductor = true; //////// } //////// else //////// { //////// IsConductor = false; //////// } ////////} //MessageBox.Show("NUmber of selected entity : " + ss.Count.ToString()); foreach (SelectedObject so in ss) { ConsolsOIs.Clear(); ClampsOIs.Clear(); Atend.Base.Acad.AT_INFO BranchInfo = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(so.ObjectId); if (BranchInfo.NodeType == (int)Atend.Control.Enum.ProductType.Conductor) { //MessageBox.Show("it was conductor"); //gConsol.Visible = true; Atend.Base.Acad.AT_SUB BranchSub = Atend.Base.Acad.AT_SUB.SelectBySelectedObjectId(so.ObjectId); foreach (Autodesk.AutoCAD.DatabaseServices.ObjectId oi in BranchSub.SubIdCollection) { Atend.Base.Acad.AT_INFO ConsolInfo = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(oi); if (ConsolInfo.NodeType == (int)Atend.Control.Enum.ProductType.Consol) { Atend.Base.Equipment.EConsol ConsolData = Atend.Base.Equipment.EConsol.AccessSelectByCode(ConsolInfo.ProductCode); if (ConsolData.ConsolType == 0 || ConsolData.ConsolType == 1) { ConsolsOIs.Add(oi); Autodesk.AutoCAD.DatabaseServices.Line BranchEntity = Atend.Global.Acad.UAcad.GetEntityByObjectID(so.ObjectId) as Autodesk.AutoCAD.DatabaseServices.Line; if (BranchEntity != null) { if (Atend.Global.Acad.UAcad.CenterOfEntity(Atend.Global.Acad.UAcad.GetEntityByObjectID(oi)) == BranchEntity.StartPoint) { StartPoleCode = new Guid(ConsolInfo.ParentCode); _BranchOi = so.ObjectId; _vol = ConsolData.VoltageLevel; } } } } } } else if (BranchInfo.NodeType == (int)Atend.Control.Enum.ProductType.SelfKeeper) { //MessageBox.Show("it was self keeper"); //gClamp.Visible = true; Atend.Base.Acad.AT_SUB BranchSub = Atend.Base.Acad.AT_SUB.SelectBySelectedObjectId(so.ObjectId); foreach (Autodesk.AutoCAD.DatabaseServices.ObjectId oi in BranchSub.SubIdCollection) { Atend.Base.Acad.AT_INFO ClampInfo = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(oi); if (ClampInfo.NodeType == (int)Atend.Control.Enum.ProductType.Kalamp) { Atend.Base.Equipment.EClamp ClampData = Atend.Base.Equipment.EClamp.AccessSelectByCode(ClampInfo.ProductCode); if (ClampData.Type != 5) { ClampsOIs.Add(oi); Autodesk.AutoCAD.DatabaseServices.Line BranchEntity = Atend.Global.Acad.UAcad.GetEntityByObjectID(so.ObjectId) as Autodesk.AutoCAD.DatabaseServices.Line; if (BranchEntity != null) { if (Atend.Global.Acad.UAcad.CenterOfEntity(Atend.Global.Acad.UAcad.GetEntityByObjectID(oi)) == BranchEntity.StartPoint) { StartPoleCode = new Guid(ClampInfo.ParentCode); _BranchOi = so.ObjectId; _vol = ClampData.VoltageLevel; } } } } } } if (ConsolsOIs.Count == 2 || ClampsOIs.Count == 2) { //if (IsConductor) //{ // if (BranchInfo.NodeType == (int)Atend.Control.Enum.ProductType.Conductor) // { SelectdEntities.Add(Atend.Global.Acad.UAcad.GetEntityByObjectID(so.ObjectId)); DataRow NewDataRow = BranchesData.NewRow(); NewDataRow["BranchCode"] = BranchInfo.NodeCode; NewDataRow["BranchType"] = Convert.ToInt32(BranchInfo.NodeType); NewDataRow["BranchOI"] = _BranchOi.ToString().Substring(1, _BranchOi.ToString().Length - 2); //NewDataRow["IsSelected"] = true; NewDataRow["Type"] = (Convert.ToInt32(BranchInfo.NodeType) == (int)Atend.Control.Enum.ProductType.Conductor ? "سیم" : "کابل خودنگهدار"); NewDataRow["Voltage"] = _vol; NewDataRow["PoleCode"] = StartPoleCode; BranchesData.Rows.Add(NewDataRow); //int NewRowIndex = gvBranches.Rows.Add(); //gvBranches.Rows[NewRowIndex].Cells["BranchCode"].Value = BranchInfo.ProductCode; //gvBranches.Rows[NewRowIndex].Cells["BranchType"].Value = Convert.ToInt32(BranchInfo.NodeType); //gvBranches.Rows[NewRowIndex].Cells["BranchOI"].Value = _BranchOi.ToString().Substring(1, _BranchOi.ToString().Length - 2); //gvBranches.Rows[NewRowIndex].Cells["IsSelected"].Value = true; //gvBranches.Rows[NewRowIndex].Cells["Type"].Value = (Convert.ToInt32(BranchInfo.NodeType) == (int)Atend.Control.Enum.ProductType.Conductor ? "سیم" : "کابل خودنگهدار"); //gvBranches.Rows[NewRowIndex].Cells["Voltage"].Value = _vol; // } // gConsol.Visible = true; // gClamp.Visible = false; //} //else //{ // if (BranchInfo.NodeType == (int)Atend.Control.Enum.ProductType.SelfKeeper) // { // SelectdEntities.Add(Atend.Global.Acad.UAcad.GetEntityByObjectID(so.ObjectId)); // } // gConsol.Visible = false; // gClamp.Visible = true; //} } } //end for } // end if (PSR.Status == PromptStatus.OK) this.Show(); DataView dv = new DataView(BranchesData); dv.RowFilter = "BranchType=" + (cboBranchType.SelectedIndex == 0 ? (int)Atend.Control.Enum.ProductType.Conductor : (int)Atend.Control.Enum.ProductType.SelfKeeper); gvBranches.DataSource = dv; //MessageBox.Show("count:" + SelectdEntities.Count.ToString()); }
public static bool DeleteKablsho(ObjectId KablshoOI) { Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; try { Atend.Base.Acad.AT_SUB sub = Atend.Base.Acad.AT_SUB.SelectBySelectedObjectId(KablshoOI); foreach (ObjectId objsub in sub.SubIdCollection) { Atend.Base.Acad.AT_INFO at_info1 = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(objsub); if (at_info1.ParentCode != "NONE" && at_info1.NodeType == (int)Atend.Control.Enum.ProductType.GroundCabel) { //Move Comment Atend.Base.Acad.AT_SUB subBranch = Atend.Base.Acad.AT_SUB.SelectBySelectedObjectId(objsub); foreach (ObjectId collect in subBranch.SubIdCollection) { Atend.Base.Acad.AT_INFO atinfo = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(collect); if (atinfo.ParentCode != "NONE" && atinfo.NodeType == (int)Atend.Control.Enum.ProductType.Comment) { if (!Atend.Global.Acad.AcadRemove.DeleteEntityByObjectId(collect)) { throw new System.Exception("Error In Delete Cabel Comment\n"); } } //Delete From AT_SUB other kablsho or headercabel if (atinfo.ParentCode != "NONE" && (atinfo.NodeType == (int)Atend.Control.Enum.ProductType.KablSho || atinfo.NodeType == (int)Atend.Control.Enum.ProductType.HeaderCabel) && collect != KablshoOI) { Atend.Base.Acad.AT_SUB.RemoveFromAT_SUB(objsub, collect); } } if (!Atend.Global.Acad.AcadRemove.DeleteEntityByObjectId(objsub)) { throw new System.Exception("Error In Delete Cabel\n"); } } if (at_info1.ParentCode != "NONE" && at_info1.NodeType == (int)Atend.Control.Enum.ProductType.Conductor) { //Move Comment Atend.Base.Acad.AT_SUB subBranch = Atend.Base.Acad.AT_SUB.SelectBySelectedObjectId(objsub); foreach (ObjectId collect in subBranch.SubIdCollection) { Atend.Base.Acad.AT_INFO atinfo = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(collect); if (atinfo.ParentCode != "NONE" && atinfo.NodeType == (int)Atend.Control.Enum.ProductType.Comment) { if (!Atend.Global.Acad.AcadRemove.DeleteEntityByObjectId(collect)) { throw new System.Exception("Error In Delete Conductor Comment\n"); } } //Delete From AT_SUB other kablsho if (atinfo.ParentCode != "NONE" && atinfo.NodeType == (int)Atend.Control.Enum.ProductType.KablSho && collect != KablshoOI) { Atend.Base.Acad.AT_SUB.RemoveFromAT_SUB(objsub, collect); } } if (!Atend.Global.Acad.AcadRemove.DeleteEntityByObjectId(objsub)) { throw new System.Exception("Error In Delete Conductor\n"); } } if (at_info1.ParentCode != "NONE" && at_info1.NodeType == (int)Atend.Control.Enum.ProductType.Comment) { if (!Atend.Global.Acad.AcadRemove.DeleteEntityByObjectId(objsub)) { throw new System.Exception("Error In Delete Comment\n"); } } if (at_info1.ParentCode != "NONE" && at_info1.NodeType == (int)Atend.Control.Enum.ProductType.Terminal) { // Comment Atend.Base.Acad.AT_SUB subBranch = Atend.Base.Acad.AT_SUB.SelectBySelectedObjectId(objsub); foreach (ObjectId collect in subBranch.SubIdCollection) { Atend.Base.Acad.AT_INFO atinfo = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(collect); //Delete From AT_SUB other kablsho if (atinfo.ParentCode != "NONE" && atinfo.NodeType == (int)Atend.Control.Enum.ProductType.KablSho && collect != KablshoOI) { Atend.Base.Acad.AT_SUB.RemoveFromAT_SUB(objsub, collect); } } if (!Atend.Global.Acad.AcadRemove.DeleteEntityByObjectId(objsub)) { throw new System.Exception("Error In Delete Termianl\n"); } } if (at_info1.ParentCode != "NONE" && at_info1.NodeType == (int)Atend.Control.Enum.ProductType.Breaker) { ObjectIdCollection CollectionBreaker = Atend.Global.Acad.UAcad.GetGroupSubEntities(objsub); foreach (ObjectId collect in CollectionBreaker) { Atend.Base.Acad.AT_INFO at_infoo = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(collect); if (at_infoo.ParentCode != "NONE" && at_infoo.NodeType == (int)Atend.Control.Enum.ProductType.Terminal) { if (!Atend.Global.Acad.DrawEquips.AcDrawBreaker.DeleteBreaker(collect)) { throw new System.Exception("Error In Delete Breaker\n"); } if (!Atend.Global.Acad.AcadRemove.DeleteEntityByObjectId(collect)) { throw new System.Exception("Error In Delete Breaker2\n"); } } } } if (at_info1.ParentCode != "NONE" && at_info1.NodeType == (int)Atend.Control.Enum.ProductType.Disconnector) { ObjectIdCollection CollectionDisconnector = Atend.Global.Acad.UAcad.GetGroupSubEntities(objsub); foreach (ObjectId collect in CollectionDisconnector) { Atend.Base.Acad.AT_INFO at_infoo = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(collect); if (at_infoo.ParentCode != "NONE" && at_infoo.NodeType == (int)Atend.Control.Enum.ProductType.Terminal) { if (!Atend.Global.Acad.DrawEquips.AcDrawDisConnector.DeleteDisconnector(collect)) { throw new System.Exception("Error In Delete Disconnector\n"); } if (!Atend.Global.Acad.AcadRemove.DeleteEntityByObjectId(collect)) { throw new System.Exception("Error In Delete Disconnector2\n"); } } } } if (at_info1.ParentCode != "NONE" && at_info1.NodeType == (int)Atend.Control.Enum.ProductType.CatOut) { ObjectIdCollection CollectionDisconnector = Atend.Global.Acad.UAcad.GetGroupSubEntities(objsub); foreach (ObjectId collect in CollectionDisconnector) { Atend.Base.Acad.AT_INFO at_infoo = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(collect); if (at_infoo.ParentCode != "NONE" && at_infoo.NodeType == (int)Atend.Control.Enum.ProductType.Terminal) { if (!Atend.Global.Acad.DrawEquips.AcDrawCatOut.DeleteCatOut(collect)) { throw new System.Exception("Error In Delete CatOut\n"); } if (!Atend.Global.Acad.AcadRemove.DeleteEntityByObjectId(collect)) { throw new System.Exception("Error In Delete CatOut2\n"); } } } } if (at_info1.ParentCode != "NONE" && (at_info1.NodeType == (int)Atend.Control.Enum.ProductType.Pole || at_info1.NodeType == (int)Atend.Control.Enum.ProductType.PoleTip)) { Atend.Base.Acad.AT_SUB.RemoveFromAT_SUB(KablshoOI, objsub); } } //+++ if (!Atend.Global.Acad.AcadRemove.DeleteEntityByObjectId(KablshoOI)) { throw new System.Exception("GRA while delete KablSho \n"); } } catch (System.Exception ex) { ed.WriteMessage("GRA ERROR KablSho : {0} \n", ex.Message); return(false); } return(true); }
public void DrawMafsal() { Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; //ed.WriteMessage("aaaaa\n"); PromptKeywordOptions PSO = new PromptKeywordOptions("\nترسیم مفصل"); PSO.Keywords.Add("New", "New", "New"); PSO.Keywords.Add("Break", "Break", "Break Cabel"); PSO.Keywords.Default = "New"; PromptResult psr = ed.GetKeywords(PSO); double MyScale = Atend.Base.Design.DProductProperties.AccessSelectBySoftwareCode((int)Atend.Control.Enum.ProductType.Mafsal).Scale; DrawMafsalJig DCP = new DrawMafsalJig(MyScale); if (psr.Status == PromptStatus.OK) { switch (psr.StringResult) { case "New": bool Conti = true; PromptResult pr; while (Conti) { pr = ed.Drag(DCP); if (pr.Status == PromptStatus.OK) { Conti = false; Entity entity = DCP.GetEntity(); if (SaveMafsalData()) { Atend.Global.Acad.UAcad.DrawEntityOnScreen(entity, Atend.Control.Enum.AutoCadLayerName.GENERAL.ToString()); Atend.Base.Acad.AT_INFO at_info = new Atend.Base.Acad.AT_INFO(entity.ObjectId); at_info.ParentCode = ""; at_info.NodeCode = MafsalInfo.Code.ToString(); at_info.NodeType = (int)Atend.Control.Enum.ProductType.Mafsal; at_info.ProductCode = Convert.ToInt32(MafsalInfo.ProductCode); at_info.Insert(); } } else { Conti = false; } } break; case "Break": PromptEntityOptions peo = new PromptEntityOptions("\nمحل برش کابل را انتخاب نمایید"); PromptEntityResult per = ed.GetEntity(peo); if (per.Status == PromptStatus.OK) { Polyline SelectedCable = Atend.Global.Acad.UAcad.GetEntityByObjectID(per.ObjectId) as Polyline; if (SelectedCable != null) { //////SelectedCable.UpgradeOpen(); //////SelectedCable.SetField("Name",new Field("Parisa", true)); int NearestSegmentIndex = 0; double NearestSegmentDistance = 100000; Point3d NearestPoint = Point3d.Origin; for (int counter = 0; counter < SelectedCable.NumberOfVertices - 1; counter++) { LineSegment3d ls1 = new LineSegment3d(SelectedCable.GetPoint3dAt(counter), SelectedCable.GetPoint3dAt(counter + 1)); Point3d SelectedPoint = ls1.GetClosestPointTo(per.PickedPoint).Point; //ed.WriteMessage("SP:{0}\n", SelectedPoint); if (SelectedPoint.DistanceTo(per.PickedPoint) < NearestSegmentDistance) { NearestSegmentDistance = SelectedPoint.DistanceTo(per.PickedPoint); NearestSegmentIndex = counter; NearestPoint = SelectedPoint; } } //ed.WriteMessage("SINDEX:{0}\n", NearestSegmentIndex); //seprate Cable Polyline Part1 = new Polyline(); Polyline Part2 = new Polyline(); for (int counter = 0; counter <= NearestSegmentIndex; counter++) { Part1.AddVertexAt(Part1.NumberOfVertices, SelectedCable.GetPoint2dAt(counter), 0, 0, 0); //ed.WriteMessage("POINT:{0}\n", SelectedCable.GetPoint2dAt(counter)); } Part1.AddVertexAt(Part1.NumberOfVertices, new Point2d(NearestPoint.X, NearestPoint.Y), 0, 0, 0); Part2.AddVertexAt(Part2.NumberOfVertices, new Point2d(NearestPoint.X, NearestPoint.Y), 0, 0, 0); for (int counter = NearestSegmentIndex + 1; counter <= SelectedCable.NumberOfVertices - 1; counter++) { Part2.AddVertexAt(Part2.NumberOfVertices, SelectedCable.GetPoint2dAt(counter), 0, 0, 0); } if (SaveMafsalData()) { try { Atend.Base.Acad.AT_INFO LastCableInfo = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(per.ObjectId); Atend.Base.Acad.AT_SUB LastCableSub = Atend.Base.Acad.AT_SUB.SelectBySelectedObjectId(per.ObjectId); //ed.WriteMessage("-3\n"); //determine header belong to part1 or part2 ObjectIdCollection Blong1 = new ObjectIdCollection(); ObjectIdCollection Blong2 = new ObjectIdCollection(); foreach (ObjectId oi in LastCableSub.SubIdCollection) { Atend.Base.Acad.AT_INFO oiInfo = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(oi); Point3d FirstPoint = SelectedCable.GetPoint3dAt(0); //ed.WriteMessage("-3.1\n"); if (oiInfo.ParentCode != "NONE" && FirstPoint != null) { //ed.WriteMessage("-3.2\n"); switch ((Atend.Control.Enum.ProductType)oiInfo.NodeType) { case Atend.Control.Enum.ProductType.Mafsal: //ed.WriteMessage("-3.3\n"); if (Atend.Global.Acad.UAcad.CenterOfEntity(Atend.Global.Acad.UAcad.GetEntityByObjectID(oi)) == FirstPoint) { //ed.WriteMessage("-3.4\n"); Blong1.Add(oi); } else { //ed.WriteMessage("-3.5\n"); Blong2.Add(oi); } break; case Atend.Control.Enum.ProductType.HeaderCabel: //ed.WriteMessage("-3.6\n"); //ed.WriteMessage("color:{0}\n",curv.ColorIndex); //ed.WriteMessage("-3.6.1\n"); if (Atend.Global.Acad.UAcad.CenterOfEntity(Atend.Global.Acad.UAcad.GetEntityByObjectID(oi)) == FirstPoint) { //ed.WriteMessage("-3.7\n"); Blong1.Add(oi); } else { //ed.WriteMessage("-3.8\n"); Blong2.Add(oi); } break; case Atend.Control.Enum.ProductType.ConnectionPoint: if (Atend.Global.Acad.UAcad.CenterOfEntity(Atend.Global.Acad.UAcad.GetEntityByObjectID(oi)) == FirstPoint) { Blong1.Add(oi); } else { Blong2.Add(oi); } break; } } } Entity MafsalEntiyt = DCP.GetDemo(NearestPoint); ObjectId NewDrawnMafsalOI = Atend.Global.Acad.UAcad.DrawEntityOnScreen(MafsalEntiyt, Atend.Control.Enum.AutoCadLayerName.GENERAL.ToString()); Atend.Base.Acad.AT_INFO newinfo1 = new Atend.Base.Acad.AT_INFO(NewDrawnMafsalOI); newinfo1.ParentCode = ""; newinfo1.NodeCode = MafsalInfo.Code.ToString(); newinfo1.NodeType = (int)Atend.Control.Enum.ProductType.Mafsal; newinfo1.ProductCode = MafsalInfo.ProductCode; newinfo1.Insert(); //ed.WriteMessage("-4\n"); Atend.Global.Acad.AcadRemove.DeleteEntityByObjectId(SelectedCable.ObjectId); //ed.WriteMessage("1\n"); Atend.Global.Acad.UAcad.DrawEntityOnScreen(Part1, Atend.Control.Enum.AutoCadLayerName.MED_GROUND.ToString()); //ed.WriteMessage("2\n"); Atend.Global.Acad.UAcad.DrawEntityOnScreen(Part2, Atend.Control.Enum.AutoCadLayerName.MED_GROUND.ToString()); //ed.WriteMessage("3\n"); Atend.Base.Acad.AT_SUB mafsalsub = new Atend.Base.Acad.AT_SUB(NewDrawnMafsalOI); mafsalsub.SubIdCollection.Add(Part1.ObjectId); mafsalsub.SubIdCollection.Add(Part2.ObjectId); mafsalsub.Insert(); //ed.WriteMessage("4\n"); LastCableInfo.SelectedObjectId = Part1.ObjectId; LastCableInfo.Insert(); ///ed.WriteMessage("5\n"); LastCableInfo.SelectedObjectId = Part2.ObjectId; LastCableInfo.Insert(); //ed.WriteMessage("6\n"); Atend.Base.Acad.AT_SUB.AddToAT_SUB(NewDrawnMafsalOI, Part1.ObjectId); foreach (ObjectId oi in Blong1) { Atend.Base.Acad.AT_SUB.AddToAT_SUB(oi, Part1.ObjectId); } Atend.Base.Acad.AT_SUB.AddToAT_SUB(NewDrawnMafsalOI, Part2.ObjectId); foreach (ObjectId oi in Blong2) { Atend.Base.Acad.AT_SUB.AddToAT_SUB(oi, Part2.ObjectId); } } catch (System.Exception ex) { ed.WriteMessage("~~~{0}~~~~~~\n", ex.Message); } } //catch ended here } } break; } } }
//~~~~~~~~~~~~~~~~~~~~~~~~~ methods ~~~~~~~~~~~~~~~~~~~~~~~~~~// public void DrawMeasuredJackPanel() { Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; bool conti = true; double MyScale = Atend.Base.Design.DProductProperties.AccessSelectBySoftwareCode((int)Atend.Control.Enum.ProductType.MeasuredJackPanel).Scale; double MyCommentScale = Atend.Base.Design.DProductProperties.AccessSelectBySoftwareCode((int)Atend.Control.Enum.ProductType.MeasuredJackPanel).CommentScale; DrawMeasuredJackPanelJig _DrawMeasuredJackPanelJig = new DrawMeasuredJackPanelJig(MyScale); PromptResult pr; while (conti) { pr = ed.Drag(_DrawMeasuredJackPanelJig); if (pr.Status == PromptStatus.OK) { conti = false; //draw entity on screen List <Entity> entities = _DrawMeasuredJackPanelJig.GetEntities(); if (SaveMeasuredJackPanelData()) { ObjectIdCollection OIC = new ObjectIdCollection(); foreach (Entity ent in entities) { OIC.Add(Atend.Global.Acad.UAcad.DrawEntityOnScreen(ent, Atend.Control.Enum.AutoCadLayerName.GENERAL.ToString())); Atend.Base.Acad.AT_INFO information = new Atend.Base.Acad.AT_INFO(OIC[OIC.Count - 1]); information.Angle = 0; information.NodeCode = MeasuredPack.Code.ToString(); information.NodeType = (int)Atend.Control.Enum.ProductType.MeasuredJackPanel; information.ParentCode = ""; information.ProductCode = eMeasuredJackPanel.Code; information.Insert(); } ObjectId GOI = Atend.Global.Acad.Global.MakeGroup(MeasuredPack.Code.ToString(), OIC); Atend.Base.Acad.AT_INFO information1 = new Atend.Base.Acad.AT_INFO(GOI); information1.Angle = 0; information1.NodeCode = MeasuredPack.Code.ToString(); information1.NodeType = (int)Atend.Control.Enum.ProductType.MeasuredJackPanel; information1.ParentCode = ""; information1.ProductCode = eMeasuredJackPanel.Code; information1.Insert(); eMeasuredJackPanel.Comment += " : " + eMeasuredJackPanel.Count.ToString(); ObjectId txtOI = Atend.Global.Acad.UAcad.DrawEntityOnScreen(Atend.Global.Acad.UAcad.WriteNote(eMeasuredJackPanel.Comment, new Point3d(_DrawMeasuredJackPanelJig.BasePoint.X, _DrawMeasuredJackPanelJig.BasePoint.Y, 0), MyCommentScale), Atend.Control.Enum.AutoCadLayerName.GENERAL.ToString()); Atend.Base.Acad.AT_INFO GroupInfo1 = new Atend.Base.Acad.AT_INFO(txtOI); GroupInfo1.ParentCode = MeasuredPack.Code.ToString(); GroupInfo1.NodeCode = ""; GroupInfo1.NodeType = (int)Atend.Control.Enum.ProductType.Comment; GroupInfo1.ProductCode = 0; GroupInfo1.Insert(); Atend.Base.Acad.AT_SUB GroupSub = new Atend.Base.Acad.AT_SUB(GOI); GroupSub.SubIdCollection.Add(txtOI); GroupSub.Insert(); } } else { conti = false; } } }
public void DrawRod() { Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; bool conti = true; ObjectIdCollection NewDrawnCollection = new ObjectIdCollection(); //ObjectId ConsolElseOI = ObjectId.Null, ConnectionOI = ObjectId.Null, RodOI = ObjectId.Null, RodTriangeOI = ObjectId.Null; double MyScale = Atend.Base.Design.DProductProperties.AccessSelectBySoftwareCode((int)Atend.Control.Enum.ProductType.Rod).Scale; double MyCommentScale = Atend.Base.Design.DProductProperties.AccessSelectBySoftwareCode((int)Atend.Control.Enum.ProductType.Rod).CommentScale; PromptEntityOptions peo = new PromptEntityOptions("\nSelect Container :"); PromptEntityResult per = ed.GetEntity(peo); if (per.Status == PromptStatus.OK) { DrawRodJig drawRod; Atend.Base.Acad.AT_INFO at_info = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(per.ObjectId); if (at_info.ParentCode != "NONE" && (at_info.NodeType == (int)Atend.Control.Enum.ProductType.Pole || at_info.NodeType == (int)Atend.Control.Enum.ProductType.PoleTip)) { drawRod = new DrawRodJig(Atend.Global.Acad.UAcad.GetEntityByObjectID(per.ObjectId), MyScale); while (conti) { PromptResult pr = ed.Drag(drawRod); if (pr.Status == PromptStatus.OK && drawRod.PartOneIsActive) { drawRod.PartOneIsActive = false; pr = ed.Drag(drawRod); if (pr.Status == PromptStatus.OK && !drawRod.PartOneIsActive) { conti = false; //ed.WriteMessage("1 \n"); #region Save Data Here List <Entity> Entities = drawRod.GetEntities(); //ed.WriteMessage("2 \n"); if (SaveRodData(at_info.NodeCode)) { // ed.WriteMessage("3 \n"); //foreach (Entity ent in Entities) //{ // NewDrawnCollection.Add(DrawEntityOnScreen(ent, Atend.Control.Enum.AutoCadLayerName.MID_AIR.ToString())); //} //--------------------- ObjectId ConsolElseOI = ObjectId.Null; foreach (Entity ent in Entities) { ObjectId newDrawnoi = Atend.Global.Acad.UAcad.DrawEntityOnScreen(ent, Atend.Control.Enum.AutoCadLayerName.MED_AIR.ToString()); Atend.Global.Acad.AcadJigs.MyPolyLine mPoly = ent as Atend.Global.Acad.AcadJigs.MyPolyLine; if (mPoly != null) { //ed.WriteMessage("POLY LINE FOUND\n"); if (mPoly.AdditionalDictionary.ContainsKey("ProductType")) { object ProductType = null; mPoly.AdditionalDictionary.TryGetValue("ProductType", out ProductType); if (ProductType != null) { if (Convert.ToInt32(ProductType) == (int)Atend.Control.Enum.ProductType.ConsolElse) { ConsolElseOI = newDrawnoi; Atend.Base.Acad.AT_INFO ConsolElseInfo = new Atend.Base.Acad.AT_INFO(newDrawnoi); ConsolElseInfo.ParentCode = at_info.NodeCode; ConsolElseInfo.NodeCode = RodPack.Code.ToString(); ConsolElseInfo.NodeType = Convert.ToInt32(ProductType); ConsolElseInfo.ProductCode = 0; ConsolElseInfo.Insert(); } } } } NewDrawnCollection.Add(newDrawnoi); } //NewDrawnCollection.Add(Atend.Global.Acad.UAcad.DrawEntityOnScreen( //Atend.Global.Acad.Global.WriteNoteMText( // Atend.Base.Equipment.ERod.SelectByCode(Atend.Base.Acad.AcadGlobal.dPackageForRod.ProductCode).Comment, // new Point3d(drawRod.CenterPoint02.X + 10, drawRod.CenterPoint02.Y, 0)), // Atend.Control.Enum.AutoCadLayerName.MID_AIR.ToString())); if (ConsolElseOI != ObjectId.Null) { Atend.Base.Acad.AT_SUB ConsolElseSub = new Atend.Base.Acad.AT_SUB(ConsolElseOI); foreach (ObjectId oi in NewDrawnCollection) { if (oi != ConsolElseOI) { //ed.WriteMessage("ConsolElseSubOI:{0}\n", oi); ConsolElseSub.SubIdCollection.Add(oi); } } ConsolElseSub.SubIdCollection.Add(per.ObjectId); ConsolElseSub.Insert(); } //--------------------- foreach (ObjectId oi in NewDrawnCollection) { if (oi != ConsolElseOI) { Atend.Base.Acad.AT_INFO a = new Atend.Base.Acad.AT_INFO(oi); a.ParentCode = at_info.NodeCode; a.NodeCode = RodPack.Code.ToString(); a.NodeType = (int)Atend.Control.Enum.ProductType.Rod; a.ProductCode = RodPack.ProductCode;; a.Insert(); } } //for (int i = 1; i <= 4; i++) //{ // ed.WriteMessage("4 \n"); // switch (i) // { // case 1: // ed.WriteMessage("5 \n"); // #region Draw & Save ConsolElse Here // ConsolElseOI = DrawAndSaveConsolElse(Entities); // #endregion // break; // case 2: // ed.WriteMessage("6 \n"); // #region Draw & Save Connection Here // ConnectionOI = DrawAndSaveConnection(Entities); // #endregion // break; // case 3: // ed.WriteMessage("7 \n"); // #region Draw & Save Rod Here // RodOI = DrawAndSaveRod(Entities); // #endregion // break; // case 4: // ed.WriteMessage("8 \n"); // #region Draw & Save RodTriangle Here // RodTriangeOI = DrawAndSaveRodTriangle(Entities); // #endregion // break; // } //} //save additional data here //ed.WriteMessage("9 \n"); //Atend.Base.Acad.AT_INFO ConsolElseInfo = new Atend.Base.Acad.AT_INFO(ConsolElseOI); //ConsolElseInfo.ParentCode = at_info.NodeCode; //ConsolElseInfo.NodeCode = Atend.Base.Acad.AcadGlobal.dPackageForRod.Code.ToString(); //ConsolElseInfo.NodeType = (int)Atend.Control.Enum.ProductType.Rod; //ConsolElseInfo.ProductCode = Atend.Base.Acad.AcadGlobal.dPackageForRod.ProductCode; //ConsolElseInfo.Insert(); //ed.WriteMessage("10 \n"); //Atend.Base.Acad.AT_SUB ConsolElseSub = new Atend.Base.Acad.AT_SUB(ConsolElseOI); //ConsolElseSub.SubIdCollection.Add(ConnectionOI); //ConsolElseSub.Insert(); //`````````````````````````` //ed.WriteMessage("11 \n"); //ConsolElseInfo = new Atend.Base.Acad.AT_INFO(ConnectionOI); //ConsolElseInfo.ParentCode = at_info.NodeCode; //ConsolElseInfo.NodeCode = Atend.Base.Acad.AcadGlobal.dPackageForRod.Code.ToString(); //ConsolElseInfo.NodeType = (int)Atend.Control.Enum.ProductType.Rod; //ConsolElseInfo.ProductCode = Atend.Base.Acad.AcadGlobal.dPackageForRod.ProductCode; //ConsolElseInfo.Insert(); //ed.WriteMessage("12 \n"); //ConsolElseSub = new Atend.Base.Acad.AT_SUB(ConnectionOI); //ConsolElseSub.SubIdCollection.Add(ConsolElseOI); //ConsolElseSub.SubIdCollection.Add(RodOI); //ConsolElseSub.Insert(); //``````````````````````````````````````````` //ed.WriteMessage("13 \n"); //ConsolElseInfo = new Atend.Base.Acad.AT_INFO(RodOI); //ConsolElseInfo.ParentCode = at_info.NodeCode; //ConsolElseInfo.NodeCode = Atend.Base.Acad.AcadGlobal.dPackageForRod.Code.ToString(); //ConsolElseInfo.NodeType = (int)Atend.Control.Enum.ProductType.Rod; //ConsolElseInfo.ProductCode = Atend.Base.Acad.AcadGlobal.dPackageForRod.ProductCode; //ConsolElseInfo.Insert(); //ed.WriteMessage("14 \n"); //ConsolElseSub = new Atend.Base.Acad.AT_SUB(RodOI); //ConsolElseSub.SubIdCollection.Add(ConnectionOI); //ConsolElseSub.SubIdCollection.Add(RodTriangeOI); //ConsolElseSub.Insert(); //``````````````````````````````````````````` //ed.WriteMessage("15 \n"); //ConsolElseInfo = new Atend.Base.Acad.AT_INFO(RodTriangeOI); //ConsolElseInfo.ParentCode = at_info.NodeCode; //ConsolElseInfo.NodeCode = Atend.Base.Acad.AcadGlobal.dPackageForRod.Code.ToString(); //ConsolElseInfo.NodeType = (int)Atend.Control.Enum.ProductType.Rod; //ConsolElseInfo.ProductCode = Atend.Base.Acad.AcadGlobal.dPackageForRod.ProductCode; //ConsolElseInfo.Insert(); //-------------------------- //ed.WriteMessage("Number of Entity : {0} \n", NewDrawnCollection.Count); ObjectId NewCreatedGroup = Atend.Global.Acad.Global.MakeGroup(RodPack.Code.ToString(), NewDrawnCollection); //Atend.Base.Equipment.ERod ERodForComment = Atend.Base.Equipment.ERod.SelectByCode(RodPack.ProductCode); //ed.WriteMessage("scale:{0} comment:{1}\n",MyCommentScale,ERod.Comment); ObjectId txtOI = Atend.Global.Acad.UAcad.DrawEntityOnScreen(Atend.Global.Acad.UAcad.WriteNote(ERod.Comment, new Point3d(drawRod.CenterPoint02.X, drawRod.CenterPoint02.Y, 0), MyCommentScale), Atend.Control.Enum.AutoCadLayerName.GENERAL.ToString()); //ed.WriteMessage("text was writen\n"); Atend.Base.Acad.AT_INFO GroupInfo1 = new Atend.Base.Acad.AT_INFO(txtOI); GroupInfo1.ParentCode = RodPack.Code.ToString(); GroupInfo1.NodeCode = ""; GroupInfo1.NodeType = (int)Atend.Control.Enum.ProductType.Comment; GroupInfo1.ProductCode = 0; GroupInfo1.Insert(); //Atend.Base.Acad.AT_INFO GroupInfo = new Atend.Base.Acad.AT_INFO(NewCreatedGroup); //GroupInfo.ParentCode = at_info.NodeCode; //GroupInfo.NodeCode = Atend.Base.Acad.AcadGlobal.dPackageForRod.Code.ToString(); //GroupInfo.NodeType = (int)Atend.Control.Enum.ProductType.BankKhazan; //GroupInfo.ProductCode = Atend.Base.Acad.AcadGlobal.dPackageForKhazanTip.ProductCode; //GroupInfo.Insert(); // Atend.Base.Equipment.EKhazanTip khazanTip = Atend.Base.Equipment.EKhazanTip.SelectByCode( // Atend.Base.Acad.AcadGlobal.dPackageForKhazanTip.ProductCode); // ObjectId txtOI = DrawEntityOnScreen( // Atend.Global.Acad.UAcad.WriteNote(khazanTip.Description, drawKhazan.GetCommentPoSition()), // Atend.Control.Enum.AutoCadLayerName.GENERAL.ToString()); Atend.Base.Acad.AT_INFO GroupInfo = new Atend.Base.Acad.AT_INFO(NewCreatedGroup); GroupInfo.ParentCode = at_info.NodeCode; GroupInfo.NodeCode = RodPack.Code.ToString(); GroupInfo.NodeType = (int)Atend.Control.Enum.ProductType.Rod; GroupInfo.ProductCode = RodPack.ProductCode; GroupInfo.Insert(); Atend.Base.Acad.AT_SUB.AddToAT_SUB(NewCreatedGroup, per.ObjectId); //ed.WriteMessage("PoleOI for KHazan:{0}", per.ObjectId); Atend.Base.Acad.AT_SUB GroupSub = new Atend.Base.Acad.AT_SUB(NewCreatedGroup); GroupSub.SubIdCollection.Add(per.ObjectId); //ed.WriteMessage("TXTOI for KHazan:{0}", txtOI); GroupSub.SubIdCollection.Add(txtOI); GroupSub.Insert(); // Atend.Base.Acad.AT_SUB.AddToAT_SUB(NewCreatedGroup, per.ObjectId); // Atend.Base.Acad.AT_SUB GroupSub = new Atend.Base.Acad.AT_SUB(NewCreatedGroup); // GroupSub.SubIdCollection.Add(per.ObjectId); // GroupSub.SubIdCollection.Add(txtOI); // GroupSub.Insert(); } #endregion } else { conti = false; } } else { conti = false; } } } } }
public static bool DeleteMeasuredJackPanel(ObjectId MeasuredJackPanelOI) { Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; try { ObjectId id = Atend.Global.Acad.UAcad.GetEntityGroup(MeasuredJackPanelOI); ObjectIdCollection Collection = Atend.Global.Acad.UAcad.GetGroupSubEntities(id); foreach (ObjectId subcolect in Collection) { Atend.Base.Acad.AT_SUB EntityS = Atend.Base.Acad.AT_SUB.SelectBySelectedObjectId(subcolect); foreach (ObjectId oisub in EntityS.SubIdCollection) { Atend.Base.Acad.AT_INFO atinfo = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(oisub); if (atinfo.ParentCode != "NONE" && atinfo.NodeType == (int)Atend.Control.Enum.ProductType.HeaderCabel) { Atend.Base.Acad.AT_SUB sub = Atend.Base.Acad.AT_SUB.SelectBySelectedObjectId(oisub); foreach (ObjectId objsub in sub.SubIdCollection) { Atend.Base.Acad.AT_INFO at_info1 = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(objsub); if (at_info1.ParentCode != "NONE" && at_info1.NodeType == (int)Atend.Control.Enum.ProductType.GroundCabel) { //Delete Comment Atend.Base.Acad.AT_SUB subBranch = Atend.Base.Acad.AT_SUB.SelectBySelectedObjectId(objsub); foreach (ObjectId collect in subBranch.SubIdCollection) { Atend.Base.Acad.AT_INFO atinfocom = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(collect); if (atinfocom.ParentCode != "NONE" && atinfocom.NodeType == (int)Atend.Control.Enum.ProductType.Comment) { if (!Atend.Global.Acad.AcadRemove.DeleteEntityByObjectId(collect)) { throw new System.Exception("Error In Delete Cabel Comment\n"); } } //Delete From AT_SUB other headercabel or kablSho if (atinfocom.ParentCode != "NONE" && (atinfocom.NodeType == (int)Atend.Control.Enum.ProductType.HeaderCabel || atinfocom.NodeType == (int)Atend.Control.Enum.ProductType.KablSho) && collect != oisub) { Atend.Base.Acad.AT_SUB.RemoveFromAT_SUB(objsub, collect); } } if (!Atend.Global.Acad.AcadRemove.DeleteEntityByObjectId(objsub)) { throw new System.Exception("Error In Delete Cabel\n"); } } if (at_info1.ParentCode != "NONE" && at_info1.NodeType == (int)Atend.Control.Enum.ProductType.Conductor) { Atend.Base.Acad.AT_SUB subBranch = Atend.Base.Acad.AT_SUB.SelectBySelectedObjectId(objsub); foreach (ObjectId collect in subBranch.SubIdCollection) { Atend.Base.Acad.AT_INFO atinfo03 = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(collect); if (atinfo03.ParentCode != "NONE" && atinfo03.NodeType == (int)Atend.Control.Enum.ProductType.Comment) { if (!Atend.Global.Acad.AcadRemove.DeleteEntityByObjectId(collect)) { throw new System.Exception("Error In Delete Conductor Comment\n"); } } //Delete From AT_SUB other headercabel if (atinfo03.ParentCode != "NONE" && atinfo03.NodeType == (int)Atend.Control.Enum.ProductType.HeaderCabel && collect != oisub) { Atend.Base.Acad.AT_SUB.RemoveFromAT_SUB(objsub, collect); } } if (!Atend.Global.Acad.AcadRemove.DeleteEntityByObjectId(objsub)) { throw new System.Exception("Error In Delete Conductor\n"); } } if (at_info1.ParentCode != "NONE" && at_info1.NodeType == (int)Atend.Control.Enum.ProductType.Comment) { if (!Atend.Global.Acad.AcadRemove.DeleteEntityByObjectId(objsub)) { throw new System.Exception("Error In Delete Comment\n"); } } } if (!Atend.Global.Acad.AcadRemove.DeleteEntityByObjectId(oisub)) { throw new System.Exception("Error In Delete HeaderCabel\n"); } } } } //+++ if (!Atend.Global.Acad.AcadRemove.DeleteEntityByObjectId(MeasuredJackPanelOI)) { throw new System.Exception("GRA while delete MeasureJackPanel \n"); } } catch (System.Exception ex) { ed.WriteMessage("GRA ERROR MeasuredJackPanel: {0} \n", ex.Message); return(false); } return(true); }
public static bool DeleteRod(ObjectId RodOI) { Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; try { ObjectId id = Atend.Global.Acad.UAcad.GetEntityGroup(RodOI); ObjectIdCollection CollectionRod = Atend.Global.Acad.UAcad.GetGroupSubEntities(id); foreach (ObjectId collect in CollectionRod) { Atend.Base.Acad.AT_INFO at_info = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(collect); if (at_info.ParentCode != "NONE" && at_info.NodeType == (int)Atend.Control.Enum.ProductType.ConsolElse) { Atend.Base.Acad.AT_SUB EntitySb = Atend.Base.Acad.AT_SUB.SelectBySelectedObjectId(RodOI); foreach (ObjectId oi in EntitySb.SubIdCollection) { Atend.Base.Acad.AT_INFO poleInfo = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(oi); if (poleInfo.ParentCode != "NONE" && (poleInfo.NodeType == (int)Atend.Control.Enum.ProductType.Pole || poleInfo.NodeType == (int)Atend.Control.Enum.ProductType.PoleTip)) { //Delete comment Atend.Base.Acad.AT_SUB EntitySb2 = Atend.Base.Acad.AT_SUB.SelectBySelectedObjectId(oi); foreach (ObjectId oisub in EntitySb2.SubIdCollection) { Atend.Base.Acad.AT_INFO poleInfosub = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(oisub); if (poleInfosub.ParentCode != "NONE" && poleInfosub.NodeType == (int)Atend.Control.Enum.ProductType.Rod) { Atend.Base.Acad.AT_SUB RodCollection = Atend.Base.Acad.AT_SUB.SelectBySelectedObjectId(oisub); foreach (ObjectId obj in RodCollection.SubIdCollection) { Atend.Base.Acad.AT_INFO at_infosub = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(obj); if (at_infosub.ParentCode != "NONE" && at_infosub.NodeType == (int)Atend.Control.Enum.ProductType.Comment) { if (!Atend.Global.Acad.AcadRemove.DeleteEntityByObjectId(obj)) { throw new System.Exception("Error In Delete Comment\n"); } } } } } //Delete from AT_SUB Atend.Base.Acad.AT_SUB.RemoveFromAT_SUB(id, oi); } } } } foreach (ObjectId collect in CollectionRod) { Atend.Base.Acad.AT_INFO at_info = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(collect); if (at_info.ParentCode != "NONE" && at_info.NodeType == (int)Atend.Control.Enum.ProductType.Rod) { if (!Atend.Global.Acad.AcadRemove.DeleteEntityByObjectId(collect)) { throw new System.Exception("Error In Delete Comment\n"); } } } //+++ if (!Atend.Global.Acad.AcadRemove.DeleteEntityByObjectId(RodOI)) { throw new System.Exception("Error In Delete Rod\n"); } } catch (System.Exception ex) { ed.WriteMessage("GRA ERROR Rod : {0} \n", ex.Message); return(false); } return(true); }
//~~~~~~~~~~~~~~~~~~~~~~~~ methods ~~~~~~~~~~~~~~~~~~~~~~~~~~~~// public void DrawLigth() { Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; bool conti = true; ObjectIdCollection NewDrawnCollection = new ObjectIdCollection(); //ObjectId ConsolElseOI = ObjectId.Null, ConnectionOI = ObjectId.Null, RodOI = ObjectId.Null, RodTriangeOI = ObjectId.Null; double MyScale = Atend.Base.Design.DProductProperties.AccessSelectBySoftwareCode((int)Atend.Control.Enum.ProductType.Light).Scale; double MyCommentScale = Atend.Base.Design.DProductProperties.AccessSelectBySoftwareCode((int)Atend.Control.Enum.ProductType.Light).CommentScale; PromptEntityOptions peo = new PromptEntityOptions("\nSelect Container :"); PromptEntityResult per = ed.GetEntity(peo); if (per.Status == PromptStatus.OK) { System.Data.DataTable Parents = Atend.Global.Acad.UAcad.DetermineParent((int)Atend.Control.Enum.ProductType.Light); Atend.Base.Acad.AT_INFO at_info = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(per.ObjectId); DataRow[] drs = Parents.Select(string.Format("SoftwareCode={0}", Convert.ToInt32(at_info.NodeType))); if (drs.Length > 0) { DrawLightJig _DrawLightJig; _DrawLightJig = new DrawLightJig(Atend.Global.Acad.UAcad.GetEntityByObjectID(per.ObjectId), MyScale); while (conti) { //p = LineSeg.GetClosestPointTo(LineEntity.StartPoint).Point; _DrawLightJig.CenterPoint01 = per.PickedPoint; _DrawLightJig.PartOneIsActive = false; PromptResult pr = ed.Drag(_DrawLightJig); if (pr.Status == PromptStatus.OK && !_DrawLightJig.PartOneIsActive) { //pr = ed.Drag(_DrawLightJig); conti = false; //ed.WriteMessage("1 \n"); #region Save Data Here List <Entity> Entities = _DrawLightJig.GetEntities(); //ed.WriteMessage("2 \n"); if (SaveLightData(new Guid(at_info.NodeCode))) { //--------------------- //ObjectId ConsolElseOI = ObjectId.Null; foreach (Entity ent in Entities) { ObjectId newDrawnoi = Atend.Global.Acad.UAcad.DrawEntityOnScreen(ent, Atend.Control.Enum.AutoCadLayerName.LOW_AIR.ToString()); ////////Atend.Global.Acad.AcadJigs.MyPolyLine mPoly = ent as Atend.Global.Acad.AcadJigs.MyPolyLine; ////////if (mPoly != null) ////////{ //////// //ed.WriteMessage("POLY LINE FOUND\n"); //////// if (mPoly.AdditionalDictionary.ContainsKey("ProductType")) //////// { //////// object ProductType = null; //////// mPoly.AdditionalDictionary.TryGetValue("ProductType", out ProductType); //////// if (ProductType != null) //////// { //////// if (Convert.ToInt32(ProductType) == (int)Atend.Control.Enum.ProductType.ConsolElse) //////// { //////// ConsolElseOI = newDrawnoi; //////// Atend.Base.Acad.AT_INFO ConsolElseInfo = new Atend.Base.Acad.AT_INFO(newDrawnoi); //////// ConsolElseInfo.ParentCode = at_info.NodeCode; //////// ConsolElseInfo.NodeCode = LightPack.Code.ToString(); //////// ConsolElseInfo.NodeType = Convert.ToInt32(ProductType); //////// ConsolElseInfo.ProductCode = 0; //////// ConsolElseInfo.Insert(); //////// } //////// } //////// } ////////} NewDrawnCollection.Add(newDrawnoi); } //////if (ConsolElseOI != ObjectId.Null) //////{ ////// Atend.Base.Acad.AT_SUB ConsolElseSub = new Atend.Base.Acad.AT_SUB(ConsolElseOI); ////// foreach (ObjectId oi in NewDrawnCollection) ////// { ////// if (oi != ConsolElseOI) ////// { ////// //ed.WriteMessage("ConsolElseSubOI:{0}\n", oi); ////// ConsolElseSub.SubIdCollection.Add(oi); ////// } ////// } ////// ConsolElseSub.SubIdCollection.Add(per.ObjectId); ////// ConsolElseSub.Insert(); //////} //--------------------- foreach (ObjectId oi in NewDrawnCollection) { //if (oi != ConsolElseOI) //{ Atend.Base.Acad.AT_INFO a = new Atend.Base.Acad.AT_INFO(oi); a.ParentCode = at_info.NodeCode; a.NodeCode = LightPack.Code.ToString(); a.NodeType = (int)Atend.Control.Enum.ProductType.Light; a.ProductCode = LightPack.ProductCode;; a.Insert(); // } } ObjectId NewCreatedGroup = Atend.Global.Acad.Global.MakeGroup(LightPack.Code.ToString(), NewDrawnCollection); ObjectId txtOI = Atend.Global.Acad.UAcad.DrawEntityOnScreen(Atend.Global.Acad.UAcad.WriteNote(eLight.Comment, new Point3d(_DrawLightJig.CenterPoint02.X, _DrawLightJig.CenterPoint02.Y, 0), MyCommentScale), Atend.Control.Enum.AutoCadLayerName.GENERAL.ToString()); Atend.Base.Acad.AT_INFO GroupInfo1 = new Atend.Base.Acad.AT_INFO(txtOI); GroupInfo1.ParentCode = LightPack.Code.ToString(); GroupInfo1.NodeCode = ""; GroupInfo1.NodeType = (int)Atend.Control.Enum.ProductType.Comment; GroupInfo1.ProductCode = 0; GroupInfo1.Insert(); Atend.Base.Acad.AT_INFO GroupInfo = new Atend.Base.Acad.AT_INFO(NewCreatedGroup); GroupInfo.ParentCode = at_info.NodeCode; GroupInfo.NodeCode = LightPack.Code.ToString(); GroupInfo.NodeType = (int)Atend.Control.Enum.ProductType.Light; GroupInfo.ProductCode = LightPack.ProductCode; GroupInfo.Insert(); Atend.Base.Acad.AT_SUB.AddToAT_SUB(NewCreatedGroup, per.ObjectId); Atend.Base.Acad.AT_SUB GroupSub = new Atend.Base.Acad.AT_SUB(NewCreatedGroup); GroupSub.SubIdCollection.Add(per.ObjectId); GroupSub.SubIdCollection.Add(txtOI); GroupSub.Insert(); } #endregion } else { conti = false; } } } else { string s = ""; foreach (DataRow dr in Parents.Rows) { s = s + Atend.Base.Design.DProductProperties.AccessSelectByCodeDrawable(Convert.ToInt32(dr["ContainerCode"])).ProductName + "-"; } Atend.Global.Acad.Notification notification = new Atend.Global.Acad.Notification(); notification.Title = "ÇÊÕÇáÇÊ ãÌÇÒ"; notification.Msg = s; notification.infoCenterBalloon(); } }//prompt status ok }
//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 ) }
//MOUSAVI->AutoPoleInstallation public ObjectId DrawKalamp(Point3d CenterPoint, ObjectId ParentOI) { Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; ObjectId HeaderOI = ObjectId.Null; double MyScale = Atend.Base.Design.DProductProperties.AccessSelectBySoftwareCode((int)Atend.Control.Enum.ProductType.Kalamp).Scale; double MyCommentScale = Atend.Base.Design.DProductProperties.AccessSelectBySoftwareCode((int)Atend.Control.Enum.ProductType.Kalamp).CommentScale; double BaseX = CenterPoint.X - 2.5; double BaseY = CenterPoint.Y; Atend.Global.Acad.AcadJigs.MyPolyLine pLine = new Atend.Global.Acad.AcadJigs.MyPolyLine(); pLine.AddVertexAt(pLine.NumberOfVertices, new Point2d(BaseX, BaseY + 5), 0, 0, 0); pLine.AddVertexAt(pLine.NumberOfVertices, new Point2d(BaseX, BaseY - 5), 0, 0, 0); pLine.AddVertexAt(pLine.NumberOfVertices, new Point2d(BaseX + 5, BaseY), 0, 0, 0); pLine.AddVertexAt(pLine.NumberOfVertices, new Point2d(BaseX, BaseY + 5), 0, 0, 0); pLine.Closed = true; if (ParentOI != ObjectId.Null) { Atend.Base.Acad.AT_INFO ParentInfo = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(ParentOI); ClampPack.ParentCode = Atend.Base.Design.DPackage.AccessSelectByNodeCode(new Guid(ParentInfo.NodeCode)).Code; //ed.WriteMessage("parent code :{0}", ParentInfo.NodeCode); } if (SaveKalampData()) { string LayerName = ""; if (eClamp.VoltageLevel == 400) { LayerName = Atend.Control.Enum.AutoCadLayerName.LOW_AIR.ToString(); } else { LayerName = Atend.Control.Enum.AutoCadLayerName.MED_AIR.ToString(); } Matrix3d trans1 = Matrix3d.Scaling(MyScale, CenterPoint); pLine.TransformBy(trans1); HeaderOI = Atend.Global.Acad.UAcad.DrawEntityOnScreen(pLine, LayerName); Atend.Base.Acad.AT_INFO at_info = new Atend.Base.Acad.AT_INFO(HeaderOI); //ed.WriteMessage("ParentCode For connection Point: {0}\n", ParentInfo.NodeCode); if (ParentOI != ObjectId.Null) { Atend.Base.Acad.AT_SUB.AddToAT_SUB(HeaderOI, ParentOI); Atend.Base.Acad.AT_INFO ParentInfo = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(ParentOI); at_info.ParentCode = ParentInfo.NodeCode; } else { at_info.ParentCode = ""; } at_info.NodeCode = ClampPack.Code.ToString(); at_info.NodeType = (int)Atend.Control.Enum.ProductType.Kalamp; at_info.ProductCode = eClamp.Code; at_info.Insert(); Atend.Base.Acad.AT_SUB ConnectionPSub = new Atend.Base.Acad.AT_SUB(HeaderOI); ConnectionPSub.SubIdCollection.Add(ParentOI); ConnectionPSub.Insert(); ObjectId TextOi = Atend.Global.Acad.UAcad.DrawEntityOnScreen(Atend.Global.Acad.UAcad.WriteNote(ClampPack.Number, Atend.Global.Acad.UAcad.CenterOfEntity(Atend.Global.Acad.UAcad.GetEntityByObjectID(HeaderOI)), MyCommentScale), Atend.Control.Enum.AutoCadLayerName.GENERAL.ToString()); Atend.Base.Acad.AT_INFO textInfo = new Atend.Base.Acad.AT_INFO(TextOi); textInfo.ParentCode = ClampPack.Code.ToString(); textInfo.NodeType = (int)Atend.Control.Enum.ProductType.Comment; textInfo.NodeCode = ""; textInfo.ProductCode = 0; textInfo.Insert(); Atend.Base.Acad.AT_SUB.AddToAT_SUB(TextOi, HeaderOI); } return(HeaderOI); }
//update from tehran 7/15 public void DrawJumper() { Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; PromptEntityOptions peo = new PromptEntityOptions(""); PromptEntityResult perOne, perTwo; ObjectId SharedPole = ObjectId.Null; Atend.Base.Acad.AT_INFO conductorInfo; Atend.Base.Acad.AT_INFO conductorInfo1; #region Conductor One peo.Message = "\nSelect First Conductor : "; perOne = ed.GetEntity(peo); if (perOne.Status == PromptStatus.OK) { conductorInfo = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(perOne.ObjectId); if (conductorInfo.ParentCode != "NONE" && (conductorInfo.NodeType == (int)Atend.Control.Enum.ProductType.Conductor || conductorInfo.NodeType == (int)Atend.Control.Enum.ProductType.SelfKeeper || conductorInfo.NodeType == (int)Atend.Control.Enum.ProductType.GroundCabel)) { JumperBtranch.LeftNodeCode = new Guid(conductorInfo.NodeCode); #region Conductor Two peo.Message = "\nSelect Second Conductor : "; perTwo = ed.GetEntity(peo); if (perTwo.Status == PromptStatus.OK) { conductorInfo1 = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(perTwo.ObjectId); if (conductorInfo1.ParentCode != "NONE" && (conductorInfo1.NodeType == (int)Atend.Control.Enum.ProductType.Conductor || conductorInfo1.NodeType == (int)Atend.Control.Enum.ProductType.SelfKeeper || conductorInfo1.NodeType == (int)Atend.Control.Enum.ProductType.GroundCabel)) { JumperBtranch.RightNodeCode = new Guid(conductorInfo1.NodeCode); JumperBtranch.Number = "Jumper"; ObjectIdCollection FirstConductorPole = new ObjectIdCollection(); Atend.Base.Acad.AT_SUB firstConductorSub = Atend.Base.Acad.AT_SUB.SelectBySelectedObjectId(perOne.ObjectId); ObjectIdCollection SecondConductorPole = new ObjectIdCollection(); Atend.Base.Acad.AT_SUB SecondConductorSub = Atend.Base.Acad.AT_SUB.SelectBySelectedObjectId(perTwo.ObjectId); foreach (ObjectId oi in firstConductorSub.SubIdCollection) { //Atend.Base.Acad.AT_INFO at_info = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(oi); //if (at_info.ParentCode != "NONE" && at_info.NodeType == (int)Atend.Control.Enum.ProductType.Consol) //{ Atend.Base.Acad.AT_SUB at_sub = Atend.Base.Acad.AT_SUB.SelectBySelectedObjectId(oi); foreach (ObjectId oii in at_sub.SubIdCollection) { Atend.Base.Acad.AT_INFO at_poleinfo = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(oii); if (at_poleinfo.ParentCode != "NONE" && at_poleinfo.NodeType == (int)Atend.Control.Enum.ProductType.Pole) { FirstConductorPole.Add(oii); } } // } } foreach (ObjectId oi in SecondConductorSub.SubIdCollection) { //Atend.Base.Acad.AT_INFO at_info = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(oi); //if (at_info.ParentCode != "NONE" && at_info.NodeType == (int)Atend.Control.Enum.ProductType.Consol) //{ Atend.Base.Acad.AT_SUB at_sub = Atend.Base.Acad.AT_SUB.SelectBySelectedObjectId(oi); foreach (ObjectId oii in at_sub.SubIdCollection) { Atend.Base.Acad.AT_INFO at_poleinfo = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(oii); if (at_poleinfo.ParentCode != "NONE" && at_poleinfo.NodeType == (int)Atend.Control.Enum.ProductType.Pole) { SecondConductorPole.Add(oii); } } //} } foreach (ObjectId oi in FirstConductorPole) { foreach (ObjectId oii in SecondConductorPole) { if (oi == oii) { SharedPole = oi; } } } // draw arc if (SharedPole != ObjectId.Null) { //Entity ContainerEntity = Atend.Global.Acad.UAcad.GetEntityByObjectID(SharedPole); //Polyline p = ContainerEntity as Polyline; //Point3d CenterPoint = Atend.Global.Acad.UAcad.CenterOfEntity(p); Point3d StartPoint = perOne.PickedPoint;; Point3d EndPoint = perTwo.PickedPoint; Line firstLine = (Line)Atend.Global.Acad.UAcad.GetEntityByObjectID(perOne.ObjectId); Line secondLine = (Line)Atend.Global.Acad.UAcad.GetEntityByObjectID(perTwo.ObjectId); if (firstLine != null && secondLine != null) { //ed.WriteMessage("\nGET CLOSEST POINT \n"); LineSegment3d ls1 = new LineSegment3d(firstLine.StartPoint, firstLine.EndPoint); LineSegment3d ls2 = new LineSegment3d(secondLine.StartPoint, secondLine.EndPoint); StartPoint = ls1.GetClosestPointTo(StartPoint).Point; EndPoint = ls2.GetClosestPointTo(EndPoint).Point; PointOnCurve3d pp = ls1.GetClosestPointTo(StartPoint); if (pp.IsOn(StartPoint)) { } pp = ls2.GetClosestPointTo(EndPoint); if (pp.IsOn(EndPoint)) { } } Entity a = CreateArcEntity(StartPoint, EndPoint); a.LayerId = firstLine.LayerId; JumperBtranch.ProductCode = conductorInfo.ProductCode; if (SaveJumperData()) { ObjectId NewArc = Atend.Global.Acad.UAcad.DrawEntityOnScreen(a, Atend.Control.Enum.AutoCadLayerName.GENERAL.ToString()); Atend.Base.Acad.AT_INFO jumperinfo = new Atend.Base.Acad.AT_INFO(NewArc); jumperinfo.NodeCode = JumperBtranch.Code.ToString(); jumperinfo.ParentCode = ""; ed.WriteMessage(" *** JUMPER PCODE : {0} \n", conductorInfo.ProductCode); jumperinfo.ProductCode = conductorInfo.ProductCode; jumperinfo.NodeType = (int)Atend.Control.Enum.ProductType.Jumper; jumperinfo.Angle = 0; jumperinfo.Insert(); Atend.Base.Acad.AT_SUB jumperSub = new Atend.Base.Acad.AT_SUB(NewArc); //ed.WriteMessage("JUMPER : {0}\n",perOne.ObjectId); jumperSub.SubIdCollection.Add(perOne.ObjectId); //ed.WriteMessage("JUMPER : {0}\n", perTwo.ObjectId); jumperSub.SubIdCollection.Add(perTwo.ObjectId); jumperSub.Insert(); Atend.Base.Acad.AT_SUB.AddToAT_SUB(NewArc, perOne.ObjectId); Atend.Base.Acad.AT_SUB.AddToAT_SUB(NewArc, perTwo.ObjectId); } } } else { return; } }//if (perTwo.Status == PromptStatus.OK) else { return; } #endregion } else { return; } } else { return; } #endregion }
//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 ) }
public static bool DeleteBreaker(ObjectId DisOI) { Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; try { ObjectIdCollection CollectionDisconnector = Atend.Global.Acad.UAcad.GetGroupSubEntities(Atend.Global.Acad.UAcad.GetEntityGroup(DisOI)); ObjectId oid = ObjectId.Null; foreach (ObjectId collect in CollectionDisconnector) { Atend.Base.Acad.AT_INFO at_infoo = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(collect); if (at_infoo.ParentCode != "NONE" && at_infoo.NodeType == (int)Atend.Control.Enum.ProductType.Terminal) { oid = collect; //CollectionDisconnector.Remove(collect); } } if (oid == ObjectId.Null) { oid = DisOI; } //Move Comment ObjectId id = Atend.Global.Acad.UAcad.GetEntityGroup(oid); Atend.Base.Acad.AT_SUB sub2 = Atend.Base.Acad.AT_SUB.SelectBySelectedObjectId(id); foreach (ObjectId h in sub2.SubIdCollection) { Atend.Base.Acad.AT_INFO at_info20 = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(h); if (at_info20.ParentCode != "NONE" && at_info20.NodeType == (int)Atend.Control.Enum.ProductType.Comment) { if (!Atend.Global.Acad.AcadRemove.DeleteEntityByObjectId(h)) { throw new System.Exception("Error In Delete Comment\n"); } } if (at_info20.ParentCode != "NONE" && at_info20.NodeType == (int)Atend.Control.Enum.ProductType.Consol) { Atend.Base.Acad.AT_SUB consolSub = Atend.Base.Acad.AT_SUB.SelectBySelectedObjectId(h); foreach (ObjectId oi in consolSub.SubIdCollection) { Atend.Base.Acad.AT_INFO at_info = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(oi); if (at_info.ParentCode != "NONE" && at_info.NodeType == (int)Atend.Control.Enum.ProductType.Breaker) { Atend.Base.Acad.AT_SUB.RemoveFromAT_SUB(oi, h); } } } } //remove Sub Group foreach (ObjectId c2 in CollectionDisconnector) { if (!Atend.Global.Acad.AcadRemove.DeleteEntityByObjectId(c2)) { ed.WriteMessage("Error In Delete Disconnector \n"); } } //+++ //if (!Atend.Global.Acad.AcadRemove.DeleteEntityByObjectId(DisOI)) //{ // throw new System.Exception("GRA while delete Breaker \n"); //} } catch (System.Exception ex) { ed.WriteMessage("GRA ERROR Breaker : {0} \n", ex.Message); return(false); } return(true); }
public void DrawKhazan() { Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; bool conti = true; //ObjectId ConsolElseOI, ConnectionOI, KhazanOI, ELse1OI, Else2OI; double MyScale = Atend.Base.Design.DProductProperties.AccessSelectBySoftwareCode((int)Atend.Control.Enum.ProductType.BankKhazan).Scale; double MyCommentScale = Atend.Base.Design.DProductProperties.AccessSelectBySoftwareCode((int)Atend.Control.Enum.ProductType.BankKhazan).CommentScale; //ed.WriteMessage("AccessSelectBySoftwareCode:{0}:{1}", MyScale, MyCommentScale); ObjectIdCollection NewDrawnCollection = new ObjectIdCollection(); DrawKhazanJig drawKhazan; PromptEntityOptions peo = new PromptEntityOptions("\nSelect Container:"); PromptEntityResult per = ed.GetEntity(peo); if (per.Status == PromptStatus.OK) { Atend.Base.Acad.AT_INFO at_info = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(per.ObjectId); if (at_info.ParentCode != "NONE" && (at_info.NodeType == (int)Atend.Control.Enum.ProductType.Pole || at_info.NodeType == (int)Atend.Control.Enum.ProductType.PoleTip)) { Entity entContainer = Atend.Global.Acad.UAcad.GetEntityByObjectID(per.ObjectId); if (entContainer != null) { drawKhazan = new DrawKhazanJig(entContainer, MyScale); //ed.WriteMessage("current scale : {0} : {1} \n", MyScale, (int)Atend.Control.Enum.ProductType.BankKhazan); while (conti) { PromptResult pr = ed.Drag(drawKhazan); if (pr.Status == PromptStatus.OK && drawKhazan.PartOneIsActive) { drawKhazan.PartOneIsActive = false; pr = ed.Drag(drawKhazan); if (pr.Status == PromptStatus.OK && !drawKhazan.PartOneIsActive) { conti = false; #region Save Data Here List <Entity> Entities = drawKhazan.GetEntities(); //ed.WriteMessage("2 \n"); if (SaveKhazanData(at_info.NodeCode)) { //ed.WriteMessage("3 \n"); ObjectId ConsolElseOI = ObjectId.Null; foreach (Entity ent in Entities) { //ed.WriteMessage("1001\n"); ObjectId newDrawnoi = Atend.Global.Acad.UAcad.DrawEntityOnScreen(ent, Atend.Control.Enum.AutoCadLayerName.MED_AIR.ToString()); Atend.Global.Acad.AcadJigs.MyPolyLine mPoly = ent as Atend.Global.Acad.AcadJigs.MyPolyLine; if (mPoly != null) { //ed.WriteMessage("POLY LINE FOUND\n"); if (mPoly.AdditionalDictionary.ContainsKey("ProductType")) { object ProductType = null; mPoly.AdditionalDictionary.TryGetValue("ProductType", out ProductType); if (ProductType != null) { if (Convert.ToInt32(ProductType) == (int)Atend.Control.Enum.ProductType.ConsolElse) { //ed.WriteMessage("1002\n"); ConsolElseOI = newDrawnoi; Atend.Base.Acad.AT_INFO ConsolElseInfo = new Atend.Base.Acad.AT_INFO(newDrawnoi); ConsolElseInfo.ParentCode = at_info.NodeCode; ConsolElseInfo.NodeCode = KhazanPack.Code.ToString(); ConsolElseInfo.NodeType = Convert.ToInt32(ProductType); ConsolElseInfo.ProductCode = 0; ConsolElseInfo.Insert(); } } } } NewDrawnCollection.Add(newDrawnoi); } //ed.WriteMessage("ConsolElseOI:{0}\n", ConsolElseOI); if (ConsolElseOI != ObjectId.Null) { Atend.Base.Acad.AT_SUB ConsolElseSub = new Atend.Base.Acad.AT_SUB(ConsolElseOI); foreach (ObjectId oi in NewDrawnCollection) { if (oi != ConsolElseOI) { //ed.WriteMessage("ConsolElseSubOI:{0}\n", oi); ConsolElseSub.SubIdCollection.Add(oi); } } ConsolElseSub.SubIdCollection.Add(per.ObjectId); ConsolElseSub.Insert(); } foreach (ObjectId oi in NewDrawnCollection) { if (oi != ConsolElseOI) { Atend.Base.Acad.AT_INFO a = new Atend.Base.Acad.AT_INFO(oi); a.ParentCode = at_info.NodeCode; a.NodeCode = KhazanPack.Code.ToString(); a.NodeType = (int)Atend.Control.Enum.ProductType.BankKhazan; a.ProductCode = KhazanPack.ProductCode; a.Insert(); } } //ed.WriteMessage("Number of Entity : {0} \n", NewDrawnCollection.Count); ObjectId NewCreatedGroup = Atend.Global.Acad.Global.MakeGroup(KhazanPack.Code.ToString(), NewDrawnCollection); ObjectId txtOI = Atend.Global.Acad.UAcad.DrawEntityOnScreen( Atend.Global.Acad.UAcad.WriteNote(eKhazanTip.Description, drawKhazan.GetCommentPoSition(), MyCommentScale), Atend.Control.Enum.AutoCadLayerName.GENERAL.ToString()); Atend.Base.Acad.AT_INFO GroupInfo1 = new Atend.Base.Acad.AT_INFO(txtOI); GroupInfo1.ParentCode = KhazanPack.Code.ToString(); GroupInfo1.NodeCode = ""; GroupInfo1.NodeType = (int)Atend.Control.Enum.ProductType.Comment; GroupInfo1.ProductCode = 0; GroupInfo1.Insert(); Atend.Base.Acad.AT_INFO GroupInfo = new Atend.Base.Acad.AT_INFO(NewCreatedGroup); GroupInfo.ParentCode = at_info.NodeCode; GroupInfo.NodeCode = KhazanPack.Code.ToString(); GroupInfo.NodeType = (int)Atend.Control.Enum.ProductType.BankKhazan; GroupInfo.ProductCode = KhazanPack.ProductCode; GroupInfo.Insert(); Atend.Base.Acad.AT_SUB.AddToAT_SUB(NewCreatedGroup, per.ObjectId); //ed.WriteMessage("PoleOI for KHazan:{0}", per.ObjectId); Atend.Base.Acad.AT_SUB GroupSub = new Atend.Base.Acad.AT_SUB(NewCreatedGroup); GroupSub.SubIdCollection.Add(per.ObjectId); //ed.WriteMessage("TXTOI for KHazan:{0}", txtOI); GroupSub.SubIdCollection.Add(txtOI); GroupSub.Insert(); } #endregion } else { conti = false; } } else { conti = false; } } } }//if it was pole } }
private void btnSelect_Click(object sender, EventArgs e) { Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; #region Select this.Hide(); PromptEntityOptions peo = new PromptEntityOptions("\nSelect MiddleJackPanel:\n"); PromptEntityResult per = ed.GetEntity(peo); if (per.Status == PromptStatus.OK) { ObjectId GroupOI = Atend.Global.Acad.Global.GetEntityGroup(per.ObjectId); if (GroupOI != ObjectId.Null) { Atend.Base.Acad.AT_INFO GroupInfo = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(GroupOI); if (GroupInfo.ParentCode != "NONE" && GroupInfo.NodeType == (int)Atend.Control.Enum.ProductType.MiddleJackPanel) { ObjectIdCollection OIC = Atend.Global.Acad.UAcad.GetGroupSubEntities(GroupOI); foreach (ObjectId oi in OIC) { Atend.Base.Acad.AT_INFO SubInfo = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(oi); if (SubInfo.ParentCode != "NONE" && SubInfo.NodeType == (int)Atend.Control.Enum.ProductType.Cell) { //ed.WriteMessage("NodeCode:{0} , CellOI:{1}\n", SubInfo.NodeCode, oi); //MyDic.Add(new Guid(SubInfo.NodeCode), oi); System.Data.DataRow NewRow1 = CellAndKey.NewRow(); NewRow1["CellGuid"] = new Guid(SubInfo.NodeCode); NewRow1["CellObjectId"] = oi.ToString().Substring(1, oi.ToString().Length - 2); Atend.Base.Acad.AT_SUB CellSub = Atend.Base.Acad.AT_SUB.SelectBySelectedObjectId(oi); foreach (ObjectId oii in CellSub.SubIdCollection) { Atend.Base.Acad.AT_INFO KeyInfo = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(oii); if (KeyInfo.ParentCode != "NONE" && KeyInfo.NodeType == (int)Atend.Control.Enum.ProductType.Key) { NewRow1["KeyObjectId"] = oii.ToString().Substring(1, oii.ToString().Length - 2); } } CellAndKey.Rows.Add(NewRow1); } } //foreach (System.Data.DataRow dr in CellAndKey.Rows) //{ // ed.WriteMessage("CG:{0},\nCOI:{1},\nKOI:{2}\n", dr["CellGuid"], dr["CellObjectId"], dr["KeyObjectId"]); //} NodeCode = new Guid(GroupInfo.NodeCode); dtCell = Atend.Base.Design.DCellStatus.AccessSelectByJackPanelCode(NodeCode); System.Data.DataColumn dcName = new System.Data.DataColumn("Name"); dtCell.Columns.Add(dcName); foreach (DataRow dr in dtCell.Rows) { //ed.WriteMessage("CellCode:{0}\n", dr["CellCode"]); Atend.Base.Design.DPackage package = Atend.Base.Design.DPackage.AccessSelectByCode(new Guid(dr["CellCode"].ToString()));// SelectByCode(new Guid(dr["CellCode"].ToString())); Atend.Base.Equipment.ECell cell = Atend.Base.Equipment.ECell.AccessSelectByCode(package.ProductCode); dr["Name"] = cell.Name; } gvCellJAckPAnel.AutoGenerateColumns = false; gvCellJAckPAnel.DataSource = dtCell; //Atend.Calculating.frmTest t = new Atend.Calculating.frmTest(); //t.dataGridView5.DataSource = dtCell; //t.ShowDialog(); } } } this.Show(); #endregion }
public void DrawKablsho() { Document doc = Application.DocumentManager.MdiActiveDocument; Editor ed = doc.Editor; //Database db = HostApplicationServices.WorkingDatabase; //Point3d TablePosition; //ObjectId NewPoleObjectId = ObjectId.Null; //ObjectIdCollection NewConsolObjectIds = new ObjectIdCollection(); //ed.WriteMessage("~~~Design scale :{0}~~~ \n", Atend.Control.Common.SelectedDesignScale); double MyScale = Atend.Base.Design.DProductProperties.AccessSelectBySoftwareCode((int)Atend.Control.Enum.ProductType.KablSho).Scale; using (DocumentLock docLock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument()) { bool conti = true; int i = 0; DrawKablshoJig _drawKalamp = new DrawKablshoJig(MyScale); ObjectId ParentOI = ObjectId.Null; string ParentCode = string.Empty; while (conti) { PromptResult pr; pr = ed.Drag(_drawKalamp); if (pr.Status == PromptStatus.OK && !_drawKalamp.GetAngle) { System.Data.DataTable PointContainerList = Atend.Global.Acad.Global.PointInsideWhichEntity(new Point3d(_drawKalamp.BasePoint.X, _drawKalamp.BasePoint.Y, 0)); System.Data.DataTable Parents = Atend.Global.Acad.UAcad.DetermineParent((int)Atend.Control.Enum.ProductType.KablSho); foreach (System.Data.DataRow dr in PointContainerList.Rows) { DataRow[] drs = Parents.Select(string.Format("SoftwareCode={0}", Convert.ToInt32(dr["Type"]))); if (drs.Length != 0) { ParentOI = new ObjectId(new IntPtr(Convert.ToInt32(dr["ObjectId"]))); ParentCode = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(ParentOI).NodeCode; //ed.WriteMessage("Value assigned $$$$$$$$$$$$$$$$$\n"); } } _drawKalamp.GetPoint = false; _drawKalamp.GetAngle = true; } else if (pr.Status == PromptStatus.OK && _drawKalamp.GetAngle) { conti = false; List <Entity> entities = _drawKalamp.GetEntities(); if (SaveKablshoData()) { foreach (Entity ent in entities) { ObjectId HOI = Atend.Global.Acad.UAcad.DrawEntityOnScreen(ent, Atend.Control.Enum.AutoCadLayerName.GENERAL.ToString()); Atend.Base.Acad.AT_INFO headerInfo = new Atend.Base.Acad.AT_INFO(HOI); headerInfo.NodeCode = KablshoPack.Code.ToString(); headerInfo.NodeType = KablshoPack.Type; headerInfo.ProductCode = eKablsho.Code; if (ParentOI != ObjectId.Null) { headerInfo.ParentCode = ParentCode; } else { headerInfo.ParentCode = ""; } headerInfo.Insert(); if (ParentOI != ObjectId.Null) { Atend.Base.Acad.AT_SUB KablshoSub = new Atend.Base.Acad.AT_SUB(HOI); KablshoSub.SubIdCollection.Add(ParentOI); KablshoSub.Insert(); Atend.Base.Acad.AT_SUB.AddToAT_SUB(HOI, ParentOI); } } } } else { conti = false; } } } }
public void SelectArea() { Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; SelectedList.Clear(); SectionCode.Clear(); #region Select this.Hide(); // ~~~~~~~~~~~~ Start Select Entities int PoleCounter = 0; int ConductorCounter = 0; PromptSelectionOptions pso = new PromptSelectionOptions(); pso.MessageForAdding = "Select area where you want: \n"; PromptSelectionResult psr = ed.GetSelection(pso); if (psr.Status == PromptStatus.OK) { SelectionSet ss = psr.Value; ObjectId[] SelectedObjectID = ss.GetObjectIds(); foreach (ObjectId so in SelectedObjectID) { Atend.Base.Acad.AT_INFO at_info = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(so); if (at_info.ParentCode != "NONE" && (at_info.NodeType == (int)Atend.Control.Enum.ProductType.Pole || at_info.NodeType == (int)Atend.Control.Enum.ProductType.PoleTip)) { Atend.Global.Calculation.General.General.AutocadSelectedList Item = new Atend.Global.Calculation.General.General.AutocadSelectedList(); Item.ProductGuid = new Guid(at_info.NodeCode); Item.ProductType = at_info.NodeType; Item.ConductorAngle = 0; string PoleNumber = ""; Atend.Base.Acad.AT_SUB poleSub = Atend.Base.Acad.AT_SUB.SelectBySelectedObjectId(so); foreach (ObjectId oi in poleSub.SubIdCollection) { Atend.Base.Acad.AT_INFO subinfo = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(oi); if (subinfo.ParentCode != "NONE" && subinfo.NodeType == (int)Atend.Control.Enum.ProductType.Comment) { MText dbt = Atend.Global.Acad.UAcad.GetEntityByObjectID(oi) as MText; if (dbt != null) { PoleNumber = dbt.Contents; } } } Item.PoleNumber = PoleNumber; SelectedList.Add(Item); PoleCounter++; } else if (at_info.ParentCode != "NONE" && at_info.NodeType == (int)Atend.Control.Enum.ProductType.Conductor) { Atend.Global.Calculation.General.General.AutocadSelectedList Item = new Atend.Global.Calculation.General.General.AutocadSelectedList(); Item.ProductGuid = new Guid(at_info.NodeCode); Item.ProductType = (int)Atend.Control.Enum.ProductType.Conductor; Item.ConductorAngle = 0; Item.PoleNumber = ""; SelectedList.Add(Item); ConductorCounter++; } else if (at_info.ParentCode != "NONE" && at_info.NodeType == (int)Atend.Control.Enum.ProductType.SelfKeeper) { Atend.Global.Calculation.General.General.AutocadSelectedList Item = new Atend.Global.Calculation.General.General.AutocadSelectedList(); Item.ProductGuid = new Guid(at_info.NodeCode); Item.ProductType = (int)Atend.Control.Enum.ProductType.SelfKeeper; Item.ConductorAngle = 0; Item.PoleNumber = ""; SelectedList.Add(Item); ConductorCounter++; } } //lblPole.Text = PoleCounter.ToString(); //lblConductor.Text = ConductorCounter.ToString(); ed.WriteMessage("Finish\n"); } else { //lblPole.Text = "0"; //lblConductor.Text = "0"; } // ~~~~~~~~~~~~ End Select Entities this.Show(); #endregion }
public ObjectId DrawKablsho02(Point3d CenterPoint) { Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; //ed.WriteMessage("CurrentPoint:{0} \n", CenterPoint); ObjectId HeaderOI = ObjectId.Null; double MyScale = Atend.Base.Design.DProductProperties.AccessSelectBySoftwareCode((int)Atend.Control.Enum.ProductType.KablSho).Scale; double MyCommentScale = Atend.Base.Design.DProductProperties.AccessSelectBySoftwareCode((int)Atend.Control.Enum.ProductType.KablSho).CommentScale; System.Data.DataTable Parents = Atend.Global.Acad.UAcad.DetermineParent((int)Atend.Control.Enum.ProductType.KablSho); System.Data.DataTable PointContainerList = Atend.Global.Acad.Global.PointInsideWhichEntity(CenterPoint); ObjectId ParentOI = ObjectId.Null; foreach (System.Data.DataRow dr in PointContainerList.Rows) { DataRow[] drs = Parents.Select(string.Format("SoftwareCode={0}", Convert.ToInt32(dr["Type"]))); if (drs.Length != 0) { ParentOI = new ObjectId(new IntPtr(Convert.ToInt32(dr["ObjectId"]))); } } double BaseX = CenterPoint.X - 2.5; double BaseY = CenterPoint.Y; Atend.Global.Acad.AcadJigs.MyPolyLine pLine = new Atend.Global.Acad.AcadJigs.MyPolyLine(); //pLine.ColorIndex = 40; pLine.AddVertexAt(pLine.NumberOfVertices, new Point2d(BaseX, BaseY + 5), 0, 0, 0); pLine.AddVertexAt(pLine.NumberOfVertices, new Point2d(BaseX, BaseY - 5), 0, 0, 0); pLine.AddVertexAt(pLine.NumberOfVertices, new Point2d(BaseX + 5, BaseY), 0, 0, 0); pLine.AddVertexAt(pLine.NumberOfVertices, new Point2d(BaseX, BaseY + 5), 0, 0, 0); pLine.Closed = true; Matrix3d trans1 = Matrix3d.Scaling(MyScale, CenterPoint); pLine.TransformBy(trans1); if (SaveKablshoData()) { string LayerName = Atend.Control.Enum.AutoCadLayerName.LOW_GROUND.ToString(); HeaderOI = Atend.Global.Acad.UAcad.DrawEntityOnScreen(pLine, LayerName); //ed.WriteMessage("HeaderOI : {0} \n", HeaderOI); Atend.Base.Acad.AT_INFO at_info = new Atend.Base.Acad.AT_INFO(HeaderOI); if (ParentOI != ObjectId.Null) { Atend.Base.Acad.AT_INFO parentInfo = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(ParentOI); //ed.WriteMessage("parentInfo.NodeCode:{0} \n", parentInfo.NodeCode); at_info.ParentCode = parentInfo.NodeCode; } else { at_info.ParentCode = ""; } //ed.WriteMessage("HeaderPack.Code:{0} \n", HeaderPack.Code); at_info.NodeCode = KablshoPack.Code.ToString(); at_info.NodeType = (int)Atend.Control.Enum.ProductType.KablSho; at_info.ProductCode = eKablsho.Code; at_info.Insert(); ObjectId TextOi = Atend.Global.Acad.UAcad.DrawEntityOnScreen(Atend.Global.Acad.UAcad.WriteNote(KablshoPack.Number, Atend.Global.Acad.UAcad.CenterOfEntity(Atend.Global.Acad.UAcad.GetEntityByObjectID(HeaderOI)), MyCommentScale), Atend.Control.Enum.AutoCadLayerName.GENERAL.ToString()); Atend.Base.Acad.AT_INFO textInfo = new Atend.Base.Acad.AT_INFO(TextOi); textInfo.ParentCode = KablshoPack.Code.ToString(); textInfo.NodeType = (int)Atend.Control.Enum.ProductType.Comment; textInfo.NodeCode = ""; textInfo.ProductCode = 0; textInfo.Insert(); Atend.Base.Acad.AT_SUB ConnectionPSub = new Atend.Base.Acad.AT_SUB(HeaderOI); ConnectionPSub.SubIdCollection.Add(TextOi); if (ParentOI != ObjectId.Null) { ConnectionPSub.SubIdCollection.Add(ParentOI); } ConnectionPSub.Insert(); if (ParentOI != ObjectId.Null) { Atend.Base.Acad.AT_SUB.AddToAT_SUB(HeaderOI, ParentOI); } } //ed.WriteMessage("return from draw header cable \n"); return(HeaderOI); }
private void btnSelect_Click(object sender, EventArgs e) { Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; SelectedList.Clear(); SectionCode.Clear(); int gvCount = gvNetCross.Rows.Count - 1; for (int i = gvCount; i >= 0; i--) { gvNetCross.Rows.RemoveAt(i); } //gvNetCross.Rows.Clear(); gvNetCross.Refresh(); section = new Atend.Global.Calculation.Section(); section.DetermineSection(); #region Select this.Hide(); // ~~~~~~~~~~~~ Start Select Entities int PoleCounter = 0; int ConductorCounter = 0; PromptSelectionOptions pso = new PromptSelectionOptions(); pso.MessageForAdding = "Select area where you want: \n"; PromptSelectionResult psr = ed.GetSelection(pso); if (psr.Status == PromptStatus.OK) { SelectionSet ss = psr.Value; ObjectId[] SelectedObjectID = ss.GetObjectIds(); foreach (ObjectId so in SelectedObjectID) { Atend.Base.Acad.AT_INFO at_info = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(so); if (at_info.ParentCode != "NONE" && (at_info.NodeType == (int)Atend.Control.Enum.ProductType.Pole || at_info.NodeType == (int)Atend.Control.Enum.ProductType.PoleTip)) { Atend.Global.Calculation.General.General.AutocadSelectedList Item = new Atend.Global.Calculation.General.General.AutocadSelectedList(); Item.ProductGuid = new Guid(at_info.NodeCode); Item.ProductType = at_info.NodeType; Item.ConductorAngle = 0; string PoleNumber = ""; Atend.Base.Acad.AT_SUB poleSub = Atend.Base.Acad.AT_SUB.SelectBySelectedObjectId(so); foreach (ObjectId oi in poleSub.SubIdCollection) { Atend.Base.Acad.AT_INFO subinfo = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(oi); if (subinfo.ParentCode != "NONE" && subinfo.NodeType == (int)Atend.Control.Enum.ProductType.Comment) { MText dbt = Atend.Global.Acad.UAcad.GetEntityByObjectID(oi) as MText; if (dbt != null) { PoleNumber = dbt.Contents; } } } Item.PoleNumber = PoleNumber; SelectedList.Add(Item); PoleCounter++; } else if (at_info.ParentCode != "NONE" && at_info.NodeType == (int)Atend.Control.Enum.ProductType.Conductor) { Atend.Global.Calculation.General.General.AutocadSelectedList Item = new Atend.Global.Calculation.General.General.AutocadSelectedList(); Item.ProductGuid = new Guid(at_info.NodeCode); Item.ProductType = (int)Atend.Control.Enum.ProductType.Conductor; Item.ConductorAngle = 0; Item.PoleNumber = ""; SelectedList.Add(Item); ConductorCounter++; } else if (at_info.ParentCode != "NONE" && at_info.NodeType == (int)Atend.Control.Enum.ProductType.SelfKeeper) { Atend.Global.Calculation.General.General.AutocadSelectedList Item = new Atend.Global.Calculation.General.General.AutocadSelectedList(); Item.ProductGuid = new Guid(at_info.NodeCode); Item.ProductType = (int)Atend.Control.Enum.ProductType.SelfKeeper; Item.ConductorAngle = 0; Item.PoleNumber = ""; SelectedList.Add(Item); ConductorCounter++; } } lblPole.Text = PoleCounter.ToString(); lblConductor.Text = ConductorCounter.ToString(); ed.WriteMessage("Finish\n"); } else { lblPole.Text = "0"; lblConductor.Text = "0"; } // ~~~~~~~~~~~~ End Select Entities this.Show(); #endregion //********************** ed.WriteMessage("~~~~~~~~~~after select \n"); dtSectionNumber = new System.Data.DataTable(); System.Data.DataColumn dcColumn = new System.Data.DataColumn("Name"); System.Data.DataColumn dcColumn1 = new System.Data.DataColumn("Code"); dtSectionNumber.Columns.Add(dcColumn); dtSectionNumber.Columns.Add(dcColumn1); Boolean chk = true; //ed.WriteMessage("SelectedList.Count= " + SelectedList.Count.ToString() + "\n"); for (int i = 0; i < SelectedList.Count; i++) { chk = true; Atend.Global.Calculation.General.General.AutocadSelectedList cadInfo = (Atend.Global.Calculation.General.General.AutocadSelectedList)SelectedList[i]; //ed.WriteMessage("Guid= "+cadInfo.ProductGuid.ToString()+"ProductType = "+cadInfo.ProductType.ToString()+"\n"); Atend.Base.Design.DPoleSection poleSection = Atend.Base.Design.DPoleSection.AccessSelectByProductCodeProductType(cadInfo.ProductGuid, cadInfo.ProductType); //ed.WriteMessage("PoleSection.SectionCode Is= "+poleSection.SectionCode.ToString()+"\n"); if (SectionCode.Count != 0) { for (int j = 0; j < SectionCode.Count; j++) { if ((Guid)SectionCode[j] == poleSection.SectionCode) { chk = false; } } if (chk) { // ed.WriteMessage("Add To SectionCode,SectionCode Is={0}\n", poleSection.SectionCode); SectionCode.Add(poleSection.SectionCode); } } else { // ed.WriteMessage("Add To SectionCode Else,SectionCode Is={0}\n", poleSection.SectionCode); SectionCode.Add(poleSection.SectionCode); } //ed.WriteMessage("SectionCodeList.Count= "+SectionCode.Count.ToString()+"\n"); } //ed.WriteMessage("Finish Full SectionCode\n"); ////Add SectionNumber To DataTable for (int i = 0; i < SectionCode.Count; i++) { //ed.WriteMessage("**Sec.Code={0}\n", SectionCode[i].ToString()); Atend.Base.Design.DSection sectionNUmber = Atend.Base.Design.DSection.AccessSelectByCode((Guid)SectionCode[i]); System.Data.DataRow dr = dtSectionNumber.NewRow(); ed.WriteMessage("Sec.Number={0},Sec.Code={1}\n", sectionNUmber.Number, sectionNUmber.Code); dr["Name"] = sectionNUmber.Number.ToString(); dr["Code"] = sectionNUmber.Code.ToString(); dtSectionNumber.Rows.Add(dr); } //ed.WriteMessage("Finsh Add SectionNumber To DataTable\n"); ////BindDataToGrid In Combo Box For NetCross DataGridViewComboBoxColumn c = (DataGridViewComboBoxColumn)gvNetCross.Columns["Column2"]; c.DisplayMember = "Name"; c.ValueMember = "Code"; c.DataSource = Atend.Base.Calculating.CNetWorkCross.AccessSelectAll(); c.Selected = true; gvNetCross.AutoGenerateColumns = false; gvNetCross.DataSource = dtSectionNumber; //Bind Data To ComboBoxSelect Section cboSelectSection.DisplayMember = "Name"; cboSelectSection.ValueMember = "Code"; cboSelectSection.DataSource = dtSectionNumber; //************************* }
public static bool DeleteStreetBox(ObjectId StreetBoxOI) { Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; try { //Move Ground Atend.Base.Acad.AT_SUB Collection1 = Atend.Base.Acad.AT_SUB.SelectBySelectedObjectId(StreetBoxOI); foreach (ObjectId obj in Collection1.SubIdCollection) { Atend.Base.Acad.AT_INFO at_info02 = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(obj); if (at_info02.ParentCode != "NONE" && at_info02.NodeType == (int)Atend.Control.Enum.ProductType.Ground) { ObjectIdCollection Coll = Atend.Global.Acad.UAcad.GetGroupSubEntities(obj); foreach (ObjectId col in Coll) { Atend.Base.Acad.AT_INFO at_info = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(col); if (at_info.ParentCode != "NONE" && at_info.NodeType == (int)Atend.Control.Enum.ProductType.Ground) { if (!Atend.Global.Acad.AcadRemove.DeleteEntityByObjectId(col)) { throw new System.Exception("Error In Delete ground\n"); } } } } } //Move Cabel ObjectId id = Atend.Global.Acad.UAcad.GetEntityGroup(StreetBoxOI); ObjectIdCollection Collection = Atend.Global.Acad.UAcad.GetGroupSubEntities(id); foreach (ObjectId collect in Collection) { Atend.Base.Acad.AT_INFO atinfo = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(collect); if (atinfo.ParentCode != "NONE" && atinfo.NodeType == (int)Atend.Control.Enum.ProductType.HeaderCabel) { Atend.Base.Acad.AT_SUB sub = Atend.Base.Acad.AT_SUB.SelectBySelectedObjectId(collect); foreach (ObjectId objsub in sub.SubIdCollection) { Atend.Base.Acad.AT_INFO at_info1 = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(objsub); if (at_info1.ParentCode != "NONE" && at_info1.NodeType == (int)Atend.Control.Enum.ProductType.GroundCabel) { //Delete Comment Atend.Base.Acad.AT_SUB subBranch = Atend.Base.Acad.AT_SUB.SelectBySelectedObjectId(objsub); foreach (ObjectId collect001 in subBranch.SubIdCollection) { Atend.Base.Acad.AT_INFO atinfo001 = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(collect001); if (atinfo001.ParentCode != "NONE" && atinfo001.NodeType == (int)Atend.Control.Enum.ProductType.Comment) { if (!Atend.Global.Acad.AcadRemove.DeleteEntityByObjectId(collect001)) { throw new System.Exception("Error In Delete Comment\n"); } } if (atinfo001.ParentCode != "NONE" && atinfo001.NodeType == (int)Atend.Control.Enum.ProductType.HeaderCabel && atinfo001.SelectedObjectId != collect) { if (!Atend.Global.Acad.AcadRemove.DeleteEntityByObjectId(objsub)) { throw new System.Exception("Error In Delete groundcabel\n"); } else { Atend.Base.Acad.AT_SUB.RemoveFromAT_SUB(objsub, collect001); } } } } } } if (!Atend.Global.Acad.AcadRemove.DeleteEntityByObjectId(collect)) { throw new System.Exception("Error In Delete Sub Streetbox\n"); } } if (!Atend.Global.Acad.AcadRemove.DeleteEntityByObjectId(StreetBoxOI)) { throw new System.Exception("GRA while delete StreetBox\n"); } } catch (System.Exception ex) { ed.WriteMessage("GRA ERROR StreetBox : {0} \n", ex.Message); return(false); } return(true); }