private void btnSelect_Click(object sender, EventArgs e) { this.Hide(); Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; PromptEntityOptions peo = new PromptEntityOptions("\nSelect Entity:"); PromptEntityResult per = ed.GetEntity(peo); Atend.Base.Acad.AT_INFO atInfo = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(per.ObjectId); if ((atInfo.NodeType == Convert.ToInt32(Atend.Control.Enum.ProductType.Consol)) || (atInfo.NodeType == Convert.ToInt32(Atend.Control.Enum.ProductType.Kalamp)) || (atInfo.NodeType == Convert.ToInt32(Atend.Control.Enum.ProductType.HeaderCabel))) { CanDoCalculate = true; consolobj = Convert.ToInt32(per.ObjectId.ToString().Substring(1, per.ObjectId.ToString().Length - 2)); Atend.Base.Design.DPackage dPack = Atend.Base.Design.DPackage.AccessSelectByCode(new Guid(atInfo.NodeCode)); if (dPack.Type == Convert.ToInt32(Atend.Control.Enum.ProductType.Kalamp)) { Atend.Base.Equipment.EClamp eClamp = Atend.Base.Equipment.EClamp.AccessSelectByCode(dPack.ProductCode); txtNamedVoltage.Text = eClamp.VoltageLevel.ToString(); txtVoltTev.Text = eClamp.VoltageLevel.ToString(); } else if (dPack.Type == Convert.ToInt32(Atend.Control.Enum.ProductType.Consol)) { Atend.Base.Equipment.EConsol eConsol = Atend.Base.Equipment.EConsol.AccessSelectByCode(dPack.ProductCode); txtNamedVoltage.Text = eConsol.VoltageLevel.ToString(); txtVoltTev.Text = eConsol.VoltageLevel.ToString(); } else if (dPack.Type == Convert.ToInt32(Atend.Control.Enum.ProductType.HeaderCabel)) { Atend.Base.Equipment.EHeaderCabel eHeaderCabel = Atend.Base.Equipment.EHeaderCabel.AccessSelectByCode(dPack.ProductCode); txtNamedVoltage.Text = eHeaderCabel.Voltage.ToString(); txtVoltTev.Text = eHeaderCabel.Voltage.ToString(); } txtR.Text = "0"; txtX.Text = "0"; } else { MessageBox.Show("لطفت جهت شروع محاسبات یک گره را انتخاب کنید"); CanDoCalculate = false; } this.Show(); }
public static bool DeleteBreakerData(ObjectId DisOI) { Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; try { Atend.Base.Acad.AT_INFO _info = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(DisOI); if (!Atend.Base.Design.DPackage.AccessDelete(new Guid(_info.NodeCode.ToString()))) { throw new System.Exception("Error In Delete Breaker\n"); } } catch (System.Exception ex) { ed.WriteMessage(" ERROR Breaker : {0} \n", ex.Message); return(false); } return(true); }
//public bool DeleteStreetBox(ObjectId StreetBoxOI) //{ // Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; // try // { // ObjectId id = Atend.Global.Acad.UAcad.GetEntityGroup(StreetBoxOI); // ObjectIdCollection Collection = Atend.Global.Acad.UAcad.GetGroupSubEntities(id); // foreach (ObjectId collect in Collection) // { // if (!Atend.Global.Acad.AcadRemove.DeleteEntityByObjectId(collect)) // { // throw new System.Exception("can not remove entity"); // } // } // /////////////////// // //Atend.Base.Acad.AT_SUB streetSub = Atend.Base.Acad.AT_SUB.SelectBySelectedObjectId(StreetBoxOI); // //foreach (ObjectId oi in streetSub.SubIdCollection) // //{ // // if (!Atend.Global.Acad.AcadRemove.DeleteEntityByObjectId(oi)) // // { // // throw new System.Exception("can not remove entity"); // // } // //} // //ObjectIdCollection OIC = Atend.Global.Acad.UAcad.GetGroupSubEntities(StreetBoxOI); // //ed.WriteMessage("++++++++ {0}\n", OIC.Count); // //foreach (ObjectId oi in OIC) // //{ // // ed.WriteMessage("@@@ {0}\n", oi); // // if (!Atend.Global.Acad.AcadRemove.DeleteEntityByObjectId(oi)) // // { // // throw new System.Exception("can not remove entity"); // // } // //} // } // catch (System.Exception ex) // { // ed.WriteMessage("Error DeleteStreetBox : {0} \n", ex.Message); // return false; // } // ed.WriteMessage("DELETE STREET BOX\n"); // return true; //} public static bool DeleteStreetBoxData(ObjectId StreetBoxOI) { Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; try { 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 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"); } } } } } //delete StreetBox Atend.Base.Acad.AT_INFO conductorinfo = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(StreetBoxOI); if (!Atend.Base.Design.DPackage.AccessDelete(new Guid(conductorinfo.NodeCode.ToString()))) { throw new System.Exception("Error In Delete dpackage\n"); } } catch (System.Exception ex) { ed.WriteMessage("Data ERROR StreetBox : {0} \n", ex.Message); return(false); } return(true); }
public static bool DeleteRodData(ObjectId RodOI, OleDbTransaction _Transaction, OleDbConnection _Connection) { Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; try { Atend.Base.Acad.AT_INFO Rodinfo = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(RodOI); if (!Atend.Base.Design.DPackage.AccessDelete(new Guid(Rodinfo.NodeCode.ToString()), _Transaction, _Connection)) { throw new System.Exception("Error In Delete DPackage\n"); } } catch (System.Exception ex) { ed.WriteMessage("Data ERROR Transaction.Rod: {0} \n", ex.Message); _Transaction.Rollback(); return(false); } return(true); }
private void btnOk_Click(object sender, EventArgs e) { for (int i = 0; i < ConductorList.Count; i++) { Atend.Global.Calculation.General.General.AutoCAdConductorList Cond = (Atend.Global.Calculation.General.General.AutoCAdConductorList)ConductorList[i]; Atend.Base.Design.DBranch Branch = Atend.Base.Design.DBranch.AccessSelectByCode(Cond.ConductorGuid); Atend.Base.Equipment.EConductorTip condTip = Atend.Base.Equipment.EConductorTip.AccessSelectByCode(Branch.ProductCode); //ed.WriteMessage("CondTip.Code= "+condTip.Code+"\n"); Atend.Base.Acad.AT_INFO at_info = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(Cond.ConductorObjectID); if (gvConductor.Rows.Count > 0) { Branch.ProductCode = Convert.ToInt32(gvConductor.Rows[gvConductor.CurrentRow.Index].Cells[0].Value.ToString()); //if (chkIsExist.CheckState == CheckState.Unchecked && cboIsExist.SelectedIndex == 0) // Branch.IsExist = 0; //if (chkIsExist.Checked && cboIsExist.SelectedIndex == 0) // Branch.IsExist = 1; //if (chkIsExist.Checked && cboIsExist.SelectedIndex == 1) // Branch.IsExist = 2; Branch.Number = condTip.Description; //if (Branch.AccessUpdate()) //{ // //EXTRA // //at_info.ProductCode = Convert.ToInt32(gvConductor.Rows[gvConductor.CurrentRow.Index].Cells[0].Value.ToString()); // at_info.ProductCode = Convert.ToInt32(gvConductor.Rows[gvConductor.CurrentRow.Index].Cells[0].Value.ToString()); // at_info.Insert(); // //ed.WriteMessage("Branch.Number= " + Branch.Number + "\n"); // //ed.WriteMessage("Branch.OBJID= " + Cond.ConductorObjectID + "\n"); // Atend.Global.Acad.UAcad.ChangeBranchText(Cond.ConductorObjectID, Branch.Number); //} //else //{ // MessageBox.Show("ويرايش امكان پذير نمي باشد"); //} } } AllowClose = true; Close(); }
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); }
private void button1_Click(object sender, EventArgs e) { this.Hide(); int ConductorCounter = 1; PromptSelectionOptions pso = new PromptSelectionOptions(); pso.MessageForAdding = "\n Select Area where you want :"; PromptSelectionResult psr = ed.GetSelection(pso); SelectionSet ss = psr.Value; ObjectId[] ids = ss.GetObjectIds(); foreach (ObjectId oi in ids) { Atend.Global.Calculation.General.General.AutoCAdConductorList Item = new Atend.Global.Calculation.General.General.AutoCAdConductorList(); Atend.Base.Acad.AT_INFO at_info = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(oi); //ed.WriteMessage("ProductCode=" + at_info.ProductCode + " nodeType= " + at_info.NodeType + "ParentCode=" + at_info.ParentCode + "\n"); if (at_info.NodeCode != "NONE" && at_info.NodeType == (int)Atend.Control.Enum.ProductType.Conductor) { //ed.WriteMessage("at_info=" + at_info.ParentCode + "\n"); Item.ConductorGuid = new Guid(at_info.NodeCode); Item.ConductorObjectID = at_info.SelectedObjectId; ConductorList.Add(Item); ConductorCounter++; } } this.Show(); lblSelected.Text = ConductorCounter.ToString(); //ed.WriteMessage("FinishSelect\n"); }
public static void AddNewBreaker(Point3d StartPoint, Point3d EndPoint, ObjectId GroupOI) { double MyScale = Atend.Base.Design.DProductProperties.AccessSelectBySoftwareCode((int)Atend.Control.Enum.ProductType.Breaker).Scale; Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; //ed.WriteMessage("start22:{0} end22:{1} \n", StartPoint, EndPoint); DrawBreakerJig _DrawBreakerJig = new DrawBreakerJig(MyScale); ObjectIdCollection OIC = new ObjectIdCollection(); foreach (Entity ent in _DrawBreakerJig.GetDemoForEdit(StartPoint, EndPoint)) { //ed.WriteMessage("each entity \n"); ObjectId NewOI = Atend.Global.Acad.UAcad.DrawEntityOnScreen(ent, Atend.Control.Enum.AutoCadLayerName.GENERAL.ToString()); OIC.Add(NewOI); Atend.Base.Acad.AT_INFO _AT_INFO = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(GroupOI); _AT_INFO.SelectedObjectId = NewOI; _AT_INFO.Insert(); //Atend.Global.Acad.UAcad.DrawEntityOnScreen(ent, Atend.Control.Enum.AutoCadLayerName.GENERAL.ToString()); } //ed.WriteMessage("add to group \n"); Atend.Global.Acad.Global.AddObjectToGroup(GroupOI, OIC); }
//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 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); }
//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 ) }
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); }
//~~~~~~~~~~~~~~~~ METHODS ~~~~~~~~~~~~~~~~~~~~~// public static void DrawForbidenArea() { Document doc = Application.DocumentManager.MdiActiveDocument; Editor ed = doc.Editor; Matrix3d ucs = ed.CurrentUserCoordinateSystem; DrawForbidenAreaJig jig = new DrawForbidenAreaJig(ucs); ObjectIdCollection ForbidenIds = new ObjectIdCollection(); bool bSuccess = true, bComplete = false; do { PromptResult res = ed.Drag(jig); bSuccess = (res.Status == PromptStatus.OK); if (bSuccess) { Polyline pl = jig.GetEntity() as Polyline; if (pl != null) { if (pl.NumberOfVertices == 1) { Point3d CurrentPoint = new Point3d(pl.GetPoint3dAt(pl.NumberOfVertices - 1).X, pl.GetPoint3dAt(pl.NumberOfVertices - 1).Y, pl.GetPoint3dAt(pl.NumberOfVertices - 1).Z); Point3d AcceptedCenterPoint = CurrentPoint; pl.SetPointAt(0, new Point2d(AcceptedCenterPoint.X, AcceptedCenterPoint.Y)); jig.AddLatestVertex(); } else { jig.AddLatestVertex(); } } } bComplete = (res.Status == PromptStatus.None); if (bComplete) { Polyline pl = jig.GetEntity() as Polyline; if (pl != null) { jig.RemoveLastVertex(); Point3d CurrentPoint = new Point3d(pl.GetPoint3dAt(pl.NumberOfVertices - 1).X, pl.GetPoint3dAt(pl.NumberOfVertices - 1).Y, pl.GetPoint3dAt(pl.NumberOfVertices - 1).Z); Point3d AcceptedCenterPoint = CurrentPoint; pl.SetPointAt(pl.NumberOfVertices - 1, new Point2d(AcceptedCenterPoint.X, AcceptedCenterPoint.Y)); } } } while (bSuccess && !bComplete); if (bComplete) { Polyline CableEntity = jig.GetEntity() as Polyline; if (CableEntity != null) { if (CableEntity.GetPoint3dAt(CableEntity.NumberOfVertices - 1) == CableEntity.GetPoint3dAt(0)) { CableEntity.Closed = true; } else { Point2d p2 = CableEntity.GetPoint2dAt(0); CableEntity.AddVertexAt(CableEntity.NumberOfVertices, p2, 0, 0, 0); CableEntity.Closed = true; } ObjectId ForbidenOI = Atend.Global.Acad.UAcad.DrawEntityOnScreen(CableEntity, Atend.Control.Enum.AutoCadLayerName.GENERAL.ToString()); ForbidenIds.Add(ForbidenOI); Atend.Base.Acad.AT_INFO forbidenInfo = new Atend.Base.Acad.AT_INFO(ForbidenOI); forbidenInfo.ParentCode = ""; forbidenInfo.NodeCode = ""; forbidenInfo.ProductCode = 0; forbidenInfo.NodeType = (int)Atend.Control.Enum.ProductType.ForbiddenArea; forbidenInfo.Angle = 0; forbidenInfo.Insert(); #region forbiden area Transaction tr = doc.TransactionManager.StartTransaction(); using (tr) { // Check the entity is a closed curve DBObject obj = tr.GetObject(CableEntity.ObjectId, OpenMode.ForRead); Curve cur = obj as Curve; if (cur != null && cur.Closed == false) { //ed.WriteMessage("\nLoop must be a closed curve."); } else { // We'll add the hatch to the model space BlockTable bt = (BlockTable)tr.GetObject(doc.Database.BlockTableId, OpenMode.ForRead); BlockTableRecord btr = (BlockTableRecord)tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite); Hatch hat = new Hatch(); hat.SetDatabaseDefaults(); // Firstly make it clear we want a gradient fill hat.HatchObjectType = HatchObjectType.GradientObject; //Let's use the pre-defined spherical gradient //LINEAR, CYLINDER, INVCYLINDER, SPHERICAL, INVSPHERICAL, HEMISPHERICAL, INVHEMISPHERICAL, CURVED, and INVCURVED. hat.SetGradient(GradientPatternType.PreDefinedGradient, "LINEAR"); // We're defining two colours hat.GradientOneColorMode = false; GradientColor[] gcs = new GradientColor[2]; // First colour must have value of 0 gcs[0] = new GradientColor(Color.FromRgb(0, 0, 255), 0); // Second colour must have value of 1 gcs[1] = new GradientColor(Color.FromRgb(47, 165, 208), 1); hat.SetGradientColors(gcs); // Add the hatch to the model space // and the transaction ObjectId hatId = btr.AppendEntity(hat); tr.AddNewlyCreatedDBObject(hat, true); // Add the hatch loop and complete the hatch ObjectIdCollection ids = new ObjectIdCollection(); ids.Add(CableEntity.ObjectId); hat.Associative = true; hat.AppendLoop(HatchLoopTypes.Default, ids); hat.EvaluateHatch(true); tr.Commit(); Atend.Base.Acad.AT_INFO forbidenInfo1 = new Atend.Base.Acad.AT_INFO(hatId); forbidenInfo1.ParentCode = ""; forbidenInfo1.NodeCode = ""; forbidenInfo1.ProductCode = 0; forbidenInfo1.NodeType = (int)Atend.Control.Enum.ProductType.ForbiddenArea; forbidenInfo1.Angle = 0; forbidenInfo1.Insert(); ForbidenIds.Add(hatId); } } #endregion Atend.Global.Acad.Global.MakeGroup(Guid.NewGuid().ToString(), ForbidenIds); } } }
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); }
public bool UpdateStreetBoxData(Guid EXCode) { Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; OleDbTransaction aTransaction; OleDbConnection aConnection = new OleDbConnection(Atend.Control.ConnectionString.AccessCnString); try { aConnection.Open(); aTransaction = aConnection.BeginTransaction(); try { StreetBoxPack = Atend.Base.Design.DPackage.AccessSelectByCode(EXCode); if (!UseAccess) { if (!eStreetBox.AccessInsert(aTransaction, aConnection, true, true)) { throw new System.Exception("eStreetBox.AccessInsert failed"); } else { foreach (Atend.Base.Equipment.EStreetBoxPhuse sbPhuses in eStreetBoxPhuse) { if (!sbPhuses.AccessInsert(aTransaction, aConnection, true, true)) { throw new System.Exception("eStreetBoxPhuse.AccessInsert failed"); } } } foreach (Atend.Base.Equipment.EStreetBoxPhuse SelectedStreetBoxPhuse in eStreetBoxPhuse) { Atend.Base.Equipment.EPhuse phuse = Atend.Base.Equipment.EPhuse.SelectByXCode(SelectedStreetBoxPhuse.PhuseXCode); if (phuse.Code != -1) { if (!phuse.AccessInsert(aTransaction, aConnection, true, true)) { throw new System.Exception("ePhuse.AccesInsert failed"); } SelectedStreetBoxPhuse.PhuseCode = phuse.Code; SelectedStreetBoxPhuse.StreetBoxCode = eStreetBox.Code; if (!SelectedStreetBoxPhuse.AccessInsert(aTransaction, aConnection, true, true)) { throw new System.Exception("EStreetBoxPhuseInsert failed"); } } else { throw new System.Exception("EPhuse.SelectByXCode failed"); } } } StreetBoxPack.IsExistance = Existance; StreetBoxPack.ProductCode = eStreetBox.Code; StreetBoxPack.ProjectCode = ProjectCode; StreetBoxPack.Number = ""; if (StreetBoxPack.AccessUpdate(aTransaction, aConnection)) { Atend.Base.Acad.AT_INFO atinfo = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(selectedObjectId); atinfo.ProductCode = eStreetBox.Code; atinfo.Insert(); } else { throw new System.Exception("StreetBoxPack.AccessInsert2 failed"); } } catch (System.Exception ex1) { ed.WriteMessage("ERROR UpdateStreetBox 01(transaction) : {0} \n", ex1.Message); aTransaction.Rollback(); aConnection.Close(); return(false); } } catch (System.Exception ex) { ed.WriteMessage("ERROR UpdateStreetBox 01 : {0} \n", ex.Message); aConnection.Close(); return(false); } aTransaction.Commit(); DeleteStreetBox(selectedObjectId); DrawStreetBoxUpdate(); aConnection.Close(); return(true); }
public void DrawStreetBoxUpdate() { bool Conti = true; PromptResult pr; Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; double MyScale = Atend.Base.Design.DProductProperties.AccessSelectBySoftwareCode((int)Atend.Control.Enum.ProductType.StreetBox).Scale; double MyCommentScale = Atend.Base.Design.DProductProperties.AccessSelectBySoftwareCode((int)Atend.Control.Enum.ProductType.StreetBox).CommentScale; DrawStreetBoxJig DSB = new DrawStreetBoxJig(eStreetBoxPhuse.Count, MyScale); while (Conti) { pr = ed.Drag(DSB); if (pr.Status == PromptStatus.OK) { Conti = false; List <Entity> ENTS = DSB.GetEntities(); //if (SaveStreetBoxData()) //{ ObjectIdCollection OIC = new ObjectIdCollection(); foreach (Entity ent in ENTS) { object ProductType = null; Atend.Global.Acad.AcadJigs.MyPolyLine mPoly = ent as Atend.Global.Acad.AcadJigs.MyPolyLine; if (mPoly != null) { //ed.WriteMessage("POLY\n"); if (mPoly.AdditionalDictionary.ContainsKey("ProductType")) { mPoly.AdditionalDictionary.TryGetValue("ProductType", out ProductType); //ed.WriteMessage("PT:{0}\n", Convert.ToInt32(ProductType)); } } else { Atend.Global.Acad.AcadJigs.MyLine mLine = ent as Atend.Global.Acad.AcadJigs.MyLine; if (mLine != null) { //ed.WriteMessage("Line\n"); if (mLine.AdditionalDictionary.ContainsKey("ProductType")) { mLine.AdditionalDictionary.TryGetValue("ProductType", out ProductType); //ed.WriteMessage("PT:{0}\n", Convert.ToInt32(ProductType)); } } else { Atend.Global.Acad.AcadJigs.MyCircle mCircle = ent as Atend.Global.Acad.AcadJigs.MyCircle; if (mCircle != null) { if (mCircle.AdditionalDictionary.ContainsKey("ProductType")) { mCircle.AdditionalDictionary.TryGetValue("ProductType", out ProductType); //ed.WriteMessage("PT:{0}\n",Convert.ToInt32(ProductType)); } } } } //~~~~~~~~~~~~~~~~~~~~~~~~~~~ ObjectId NewDrawnOI = Atend.Global.Acad.UAcad.DrawEntityOnScreen(ent, Atend.Control.Enum.AutoCadLayerName.MED_GROUND.ToString()); OIC.Add(NewDrawnOI); Atend.Base.Acad.AT_INFO info = new Atend.Base.Acad.AT_INFO(NewDrawnOI); info.ParentCode = ""; info.ProductCode = StreetBoxPack.ProductCode; info.NodeCode = StreetBoxPack.Code.ToString(); if (ProductType != null) { info.NodeType = Convert.ToInt32(ProductType); } else { info.NodeType = 0; } info.Insert(); //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } //text will add here ObjectId TextOi = Atend.Global.Acad.UAcad.DrawEntityOnScreen( Atend.Global.Acad.UAcad.WriteNote(eStreetBox.Comment, new Point3d(DSB.MyBasePoint.X, DSB.MyBasePoint.Y, DSB.MyBasePoint.Z), MyCommentScale) , Atend.Control.Enum.AutoCadLayerName.GENERAL.ToString() ); OIC.Add(TextOi); Atend.Base.Acad.AT_INFO Textinfo = new Atend.Base.Acad.AT_INFO(TextOi); Textinfo.ParentCode = StreetBoxPack.Code.ToString(); Textinfo.ProductCode = 0; Textinfo.NodeCode = ""; Textinfo.NodeType = (int)Atend.Control.Enum.ProductType.Comment; Textinfo.Insert(); ObjectId GOI = Atend.Global.Acad.Global.MakeGroup(Guid.NewGuid().ToString(), OIC); if (GOI != ObjectId.Null) { Atend.Base.Acad.AT_INFO GInfo = new Atend.Base.Acad.AT_INFO(GOI); GInfo.ParentCode = ""; GInfo.NodeCode = StreetBoxPack.Code.ToString(); GInfo.NodeType = (int)Atend.Control.Enum.ProductType.StreetBox; GInfo.ProductCode = StreetBoxPack.ProductCode; GInfo.Insert(); //Atend.Base.Acad.AT_SUB StreetboxSub = new Atend.Base.Acad.AT_SUB(GOI); //StreetboxSub.SubIdCollection.Add(TextOi); //StreetboxSub.Insert(); } //} } 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 bool UpdatebreakerData(Guid EXCode) { Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; OleDbTransaction aTransaction; OleDbConnection aConnection = new OleDbConnection(Atend.Control.ConnectionString.AccessCnString); try { aConnection.Open(); aTransaction = aConnection.BeginTransaction(); try { BreakerPack = Atend.Base.Design.DPackage.AccessSelectByCode(EXCode); if (!UseAccess) { if (!eBreaker.AccessInsert(aTransaction, aConnection, true, true)) { throw new System.Exception("eBreaker.AccessInsert failed"); } //if (!Atend.Base.Equipment.EOperation.SentFromLocalToAccess(eBreaker.XCode, (int)Atend.Control.Enum.ProductType.Breaker, eBreaker.Code, aTransaction, aConnection)) //{ // throw new System.Exception("operation failed"); //} } BreakerPack.IsExistance = Existance; BreakerPack.ProductCode = eBreaker.Code; BreakerPack.ProjectCode = ProjectCode; BreakerPack.Number = ""; if (BreakerPack.AccessUpdate(aTransaction, aConnection)) { Atend.Base.Acad.AT_INFO atinfo = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(selectedObjectId);// id); atinfo.ProductCode = eBreaker.Code; atinfo.Insert(); ChangeComment(Atend.Global.Acad.UAcad.GetEntityGroup(selectedObjectId), eBreaker.Comment); } else { throw new System.Exception("BreakerPack.AccessInsert2 failed"); } if (!DKeyStatus.Update(aTransaction, aConnection)) { throw new System.Exception("dKeyStatus.AccessUpdate Failed"); } if (!UseAccess) { //if (Br.Code == -1) //{ //WENT TO //if (!Atend.Base.Equipment.EContainerPackage.SentFromLocalToAccess(eBreaker.XCode, (int)Atend.Control.Enum.ProductType.Breaker, eBreaker.Code, aTransaction, aConnection)) //{ // throw new System.Exception("SentFromLocalToAccess failed"); //} //} } } catch (System.Exception ex1) { ed.WriteMessage("ERROR UpdateBreaker 01(transaction) : {0} \n", ex1.Message); aTransaction.Rollback(); aConnection.Close(); return(false); } } catch (System.Exception ex) { ed.WriteMessage("ERROR UpdateBreaker 01 : {0} \n", ex.Message); aConnection.Close(); return(false); } aTransaction.Commit(); aConnection.Close(); return(true); }
public bool ChangeBranchInfo() { OleDbConnection conection = new OleDbConnection(Atend.Control.ConnectionString.AccessCnString); OleDbTransaction transaction; Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; try { conection.Open(); transaction = conection.BeginTransaction(); try { int ConductorCounter = 0; int SelfkeeperCounter = 0; int GroundCabelCounter = 0; foreach (Atend.Base.Design.DBranch branch in dBranch) { ObjectId obj = Atend.Global.Acad.UAcad.GetBranchByGuid(branch.Code); Atend.Base.Acad.AT_INFO atInfo = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(obj); #region Conductor if (branch.ProductType == Convert.ToInt32(Atend.Control.Enum.ProductType.Conductor)) { Atend.Base.Equipment.EConductor CondPhase = Atend.Base.Equipment.EConductor.SelectByXCode(CondTip[ConductorCounter].PhaseProductXCode); Atend.Base.Equipment.EConductor CondNeutral = Atend.Base.Equipment.EConductor.SelectByXCode(CondTip[ConductorCounter].NeutralProductXCode); Atend.Base.Equipment.EConductor CondNight = Atend.Base.Equipment.EConductor.SelectByXCode(CondTip[ConductorCounter].NightProductXCode); if (!CondPhase.AccessInsert(transaction, conection, true, true)) { throw new System.Exception("Insert Failed"); } if (!CondNeutral.AccessInsert(transaction, conection, true, true)) { throw new System.Exception("Insert Failed"); } if (!CondNight.AccessInsert(transaction, conection, true, true)) { } CondTip[ConductorCounter].PhaseProductCode = CondPhase.Code; CondTip[ConductorCounter].NeutralProductCode = CondNeutral.Code; CondTip[ConductorCounter].NightProductCode = CondNight.Code; if (!CondTip[ConductorCounter].AccessInsert(transaction, conection, true, true)) { throw new System.Exception("Insert Tip Failed"); } branch.ProductCode = CondTip[ConductorCounter].Code; branch.Number = CondTip[ConductorCounter].Description; atInfo.ProductCode = condTip[ConductorCounter].Code; if (branch.AccessUpdate(transaction, conection)) { Atend.Global.Acad.DrawEquips.AcDrawConductor.ChangeCounductorComment(obj, CondTip[ConductorCounter].Description); atInfo.Insert(); } else { throw new System.Exception("Insert Branch Failed"); } ConductorCounter++; } #endregion #region SelfKeeper if (branch.ProductType == Convert.ToInt32(Atend.Control.Enum.ProductType.SelfKeeper)) { Atend.Base.Equipment.ESelfKeeper SelfPhase = Atend.Base.Equipment.ESelfKeeper.SelectByXCode(SelfTip[SelfkeeperCounter].PhaseProductxCode); Atend.Base.Equipment.ESelfKeeper SelfNeutral = Atend.Base.Equipment.ESelfKeeper.SelectByXCode(SelfTip[SelfkeeperCounter].NeutralProductxCode); Atend.Base.Equipment.ESelfKeeper SelfNight = Atend.Base.Equipment.ESelfKeeper.SelectByXCode(SelfTip[SelfkeeperCounter].NightProductxCode); if (!SelfPhase.AccessInsert(transaction, conection, true, true)) { throw new System.Exception("Insert Failed"); } if (!SelfNeutral.AccessInsert(transaction, conection, true, true)) { throw new System.Exception("Insert Failed"); } if (!SelfNight.AccessInsert(transaction, conection, true, true)) { throw new System.Exception("Insert Failed"); } SelfTip[SelfkeeperCounter].PhaseProductCode = SelfPhase.Code; SelfTip[SelfkeeperCounter].NeutralProductCode = SelfNeutral.Code; SelfTip[SelfkeeperCounter].NightProductCode = SelfNight.Code; if (!SelfTip[SelfkeeperCounter].AccessInsert(transaction, conection)) { throw new System.Exception("Insert Tip Failed"); } branch.ProductCode = SelfTip[SelfkeeperCounter].Code; branch.Number = SelfTip[SelfkeeperCounter].Description; atInfo.ProductCode = SelfTip[SelfkeeperCounter].Code; if (branch.AccessUpdate(transaction, conection)) { Atend.Global.Acad.DrawEquips.AcDrawSelfKeeper.ChangeCabelComment(obj, SelfTip[SelfkeeperCounter].Description); atInfo.Insert(); } else { throw new System.Exception("Insert Branch Failed"); } SelfkeeperCounter++; } #endregion #region GroundCabel if (branch.ProductType == Convert.ToInt32(Atend.Control.Enum.ProductType.GroundCabel)) { Atend.Base.Equipment.EGroundCabel GroundPhase = Atend.Base.Equipment.EGroundCabel.SelectByXCode(GroundTip[GroundCabelCounter].PhaseProductXCode); Atend.Base.Equipment.EGroundCabel GroundNeutral = Atend.Base.Equipment.EGroundCabel.SelectByXCode(GroundTip[GroundCabelCounter].NeutralProductXCode); //Atend.Base.Equipment.EGroundCabel GroundNight = Atend.Base.Equipment.EGroundCabel.SelectByXCode(GroundTip[GroundCabelCounter].NightProductxCode); if (!GroundPhase.AccessInsert(transaction, conection, true, true)) { throw new System.Exception("Insert Failed"); } if (!GroundNeutral.AccessInsert(transaction, conection, true, true)) { throw new System.Exception("Insert Failed"); } //if (!GroundNight.AccessInsert(transaction, conection, true, true)) //{ // throw new System.Exception("Insert Failed"); //} GroundTip[GroundCabelCounter].PhaseProductCode = GroundPhase.Code; GroundTip[GroundCabelCounter].NeutralProductCode = GroundNeutral.Code; //GroundTip[GroundCabelCounter].NightProductCode = GroundNight.Code; if (!GroundTip[GroundCabelCounter].AccessInsert(transaction, conection, true, true)) { throw new System.Exception("Insert Tip Failed"); } branch.ProductCode = GroundTip[GroundCabelCounter].Code; branch.Number = GroundTip[GroundCabelCounter].Description; atInfo.ProductCode = GroundTip[GroundCabelCounter].Code; if (branch.AccessUpdate(transaction, conection)) { Atend.Global.Acad.DrawEquips.AcDrawGroundCabel.ChangeCabelComment(obj, GroundTip[GroundCabelCounter].Description); atInfo.Insert(); } else { throw new System.Exception("Insert Branch Failed"); } GroundCabelCounter++; } #endregion } } catch (System.Exception ex) { ed.WriteMessage("Error In 01={0}\n", ex.Message); transaction.Rollback(); conection.Close(); return(false); } } catch (System.Exception ex1) { ed.WriteMessage("Error in 02={0}\n", ex1.Message); conection.Close(); return(false); } transaction.Commit(); conection.Close(); return(true); }
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); }
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 }
//~~~~~~~~~~~~~~~~~~~~~~~~ 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 }
public void DrawWeekJackPanel(Entity PostContainerEntity, int CellCount, ref DataRow[] PostEquipInserted) { Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; bool conti = true; Guid NodeCode = new Guid(PostEquipInserted[0]["NodeCode"].ToString()); Guid ParentCode = new Guid(PostEquipInserted[0]["ParentCode"].ToString()); int ProductCode = Convert.ToInt32(PostEquipInserted[0]["ProductCode"]); double MyScale = Atend.Base.Design.DProductProperties.AccessSelectBySoftwareCode((int)Atend.Control.Enum.ProductType.WeekJackPanel).Scale; //ed.WriteMessage("DrawWeekJackPanel 01 \n"); DrawWeekJackPanelJig MidJ = new DrawWeekJackPanelJig(PostContainerEntity, CellCount, MyScale, ref PostEquipInserted); PromptResult pr; while (conti) { pr = ed.Drag(MidJ); if (pr.Status == PromptStatus.OK) { conti = false; #region save data here ObjectIdCollection OIC = new ObjectIdCollection(); ObjectIdCollection HeadersOI = new ObjectIdCollection(); //ed.WriteMessage("DrawWeekJackPanel 02 \n"); List <Entity> Entities = new List <Entity>(); //ed.WriteMessage("DrawWeekJackPanel 03 \n"); Entities = MidJ.GetEntities(); //ed.WriteMessage("DrawWeekJackPanel 04 \n"); foreach (Entity ent in Entities) { Atend.Global.Acad.AcadJigs.MyPolyLine HeaderCablePoly = ent as Atend.Global.Acad.AcadJigs.MyPolyLine; //ed.WriteMessage("DrawWeekJackPanel 05 \n"); if (HeaderCablePoly != null) { ObjectId hoi = Atend.Global.Acad.UAcad.DrawEntityOnScreen(ent, Atend.Control.Enum.AutoCadLayerName.LOW_GROUND.ToString()); HeadersOI.Add(hoi); OIC.Add(hoi); //ed.WriteMessage("DrawWeekJackPanel 06 \n"); } else { ObjectId NOI = Atend.Global.Acad.UAcad.DrawEntityOnScreen(ent, Atend.Control.Enum.AutoCadLayerName.MED_GROUND.ToString()); if (NOI != ObjectId.Null) { OIC.Add(NOI); Atend.Base.Acad.AT_INFO HeaderInfo = new Atend.Base.Acad.AT_INFO(NOI); HeaderInfo.ParentCode = NodeCode.ToString(); HeaderInfo.NodeCode = ""; HeaderInfo.NodeType = (int)Atend.Control.Enum.ProductType.WeekJackPanel; HeaderInfo.ProductCode = 0; HeaderInfo.Insert(); } //ed.WriteMessage("DrawWeekJackPanel 07 \n"); } } try { foreach (ObjectId HeaderOI in HeadersOI) { Atend.Base.Acad.AT_INFO HeaderInfo = new Atend.Base.Acad.AT_INFO(HeaderOI); //ed.WriteMessage("Header Parent :{0}\n", p.CodeGuid); HeaderInfo.ParentCode = NodeCode.ToString(); HeaderInfo.NodeCode = ""; HeaderInfo.NodeType = (int)Atend.Control.Enum.ProductType.HeaderCabel; HeaderInfo.ProductCode = 0; HeaderInfo.Insert(); } ObjectId WeekGroup = Atend.Global.Acad.Global.MakeGroup(NodeCode.ToString(), OIC); if (WeekGroup != ObjectId.Null) { Atend.Base.Acad.AT_INFO WeekInfo = new Atend.Base.Acad.AT_INFO(WeekGroup); //ed.WriteMessage(">>>>>>Header Parent :{0} , WeekCode :{1} \n", p.ParentCode, p.CodeGuid); WeekInfo.ParentCode = ParentCode.ToString(); WeekInfo.NodeCode = NodeCode.ToString(); WeekInfo.NodeType = (int)Atend.Control.Enum.ProductType.WeekJackPanel; WeekInfo.ProductCode = ProductCode; WeekInfo.Insert(); //ed.WriteMessage("ADD TO POST WEEK\n"); Atend.Base.Acad.AT_SUB.AddToAT_SUB(WeekGroup, PostContainerEntity.ObjectId); Atend.Base.Acad.AT_SUB.AddToAT_SUB(PostContainerEntity.ObjectId, WeekGroup); } } catch (System.Exception ex) { ed.WriteMessage("Error DrawWeekJackPanel : {0} \n", ex.Message); } #endregion } } }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //public void DrawMiddleJackPanel(Entity PostEntity, System.Data.DataTable AllData) //{ // Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; // bool conti = true; // //Dictionary<Guid, List<Entity>> MyCells = new Dictionary<Guid, List<Entity>>(); // double MyScale = Atend.Base.Design.DProductProperties.AccessSelectBySoftwareCode((int)Atend.Control.Enum.ProductType.MiddleJackPanel).Scale; // DrawMiddleJackPanelJig MidJ = new DrawMiddleJackPanelJig(PostContainerEntity, MyScale); // MidJ.MiddleJackPanelProductCode = ProductCode; // MidJ.MiddleJaclPanelParentCode = ParentCode; // MidJ.Cells = JackpanelCells; // PromptResult pr; // while (conti) // { // pr = ed.Drag(MidJ); // if (pr.Status == PromptStatus.OK) // { // conti = false; // #region save data here // ObjectIdCollection OIC = new ObjectIdCollection(); // List<Guid> CellsGuid = new List<Guid>(); // List<Entity> Entities = new List<Entity>(); // Entities = MidJ.GetEntities(); // //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // #region Seprate different cells from each other // foreach (Entity ent in Entities) // { // Atend.Global.Acad.AcadJigs.MyPolyLine poly = ent as Atend.Global.Acad.AcadJigs.MyPolyLine; // object CellCode = null; // if (poly != null) // { // if (poly.AdditionalDictionary.ContainsKey("Code")) // { // poly.AdditionalDictionary.TryGetValue("Code", out CellCode); // } // } // else // { // Atend.Global.Acad.AcadJigs.MyLine lin = ent as Atend.Global.Acad.AcadJigs.MyLine; // if (lin != null) // { // if (lin.AdditionalDictionary.ContainsKey("Code")) // { // lin.AdditionalDictionary.TryGetValue("Code", out CellCode); // } // } // else // { // Atend.Global.Acad.AcadJigs.MyCircle cir = ent as Atend.Global.Acad.AcadJigs.MyCircle; // if (cir != null) // { // if (cir.AdditionalDictionary.ContainsKey("Code")) // { // cir.AdditionalDictionary.TryGetValue("Code", out CellCode); // } // } // } // } // if (CellCode != null) // { // if (!MyCells.ContainsKey(new Guid(CellCode.ToString()))) // { // MyCells.Add(new Guid(CellCode.ToString()), new List<Entity>()); // CellsGuid.Add(new Guid(CellCode.ToString())); // List<Entity> Entities1; // MyCells.TryGetValue(new Guid(CellCode.ToString()), out Entities1); // Entities1.Add(ent); // } // else // { // List<Entity> Entities1; // MyCells.TryGetValue(new Guid(CellCode.ToString()), out Entities1); // Entities1.Add(ent); // } // } // } // #endregion // //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ObjectIdCollection BusOIs = new ObjectIdCollection(); // foreach (Guid _ExistGuid in MyCells.Keys) // { // try // { // #region Draw different cells // List<Entity> MyList = null; // MyCells.TryGetValue(_ExistGuid, out MyList); // if (MyList != null) // { // ObjectIdCollection CurrentCellEntities = new ObjectIdCollection(); // ObjectId CurrentCellObjectId = ObjectId.Null; // foreach (Entity ent in MyList) // { // object MyProductType = null; // object MYProductCode = null; // object myCodeGuid = null; // Atend.Global.Acad.AcadJigs.MyPolyLine poly = ent as Atend.Global.Acad.AcadJigs.MyPolyLine; // if (poly != null) // { // if (poly.AdditionalDictionary.ContainsKey("Code")) // { // poly.AdditionalDictionary.TryGetValue("Code", out myCodeGuid); // } // if (poly.AdditionalDictionary.ContainsKey("ProductType")) // { // poly.AdditionalDictionary.TryGetValue("ProductType", out MyProductType); // } // if (poly.AdditionalDictionary.ContainsKey("ProductCode")) // { // poly.AdditionalDictionary.TryGetValue("ProductCode", out MYProductCode); // } // } // else // { // Atend.Global.Acad.AcadJigs.MyLine lin = ent as Atend.Global.Acad.AcadJigs.MyLine; // if (lin != null) // { // if (lin.AdditionalDictionary.ContainsKey("Code")) // { // lin.AdditionalDictionary.TryGetValue("Code", out myCodeGuid); // } // if (lin.AdditionalDictionary.ContainsKey("ProductType")) // { // lin.AdditionalDictionary.TryGetValue("ProductType", out MyProductType); // } // if (lin.AdditionalDictionary.ContainsKey("ProductCode")) // { // lin.AdditionalDictionary.TryGetValue("ProductCode", out MYProductCode); // } // } // else // { // Atend.Global.Acad.AcadJigs.MyCircle cir = ent as Atend.Global.Acad.AcadJigs.MyCircle; // if (cir != null) // { // if (cir.AdditionalDictionary.ContainsKey("Code")) // { // cir.AdditionalDictionary.TryGetValue("Code", out myCodeGuid); // } // if (cir.AdditionalDictionary.ContainsKey("ProductType")) // { // cir.AdditionalDictionary.TryGetValue("ProductType", out MyProductType); // } // if (cir.AdditionalDictionary.ContainsKey("ProductCode")) // { // cir.AdditionalDictionary.TryGetValue("ProductCode", out MYProductCode); // } // } // } // } // //------------------------ // ObjectId NewCellEntities = Atend.Global.Acad.UAcad.DrawEntityOnScreen(ent, Atend.Control.Enum.AutoCadLayerName.MED_GROUND.ToString()); // OIC.Add(NewCellEntities); // if (MyProductType != null) // { // if (Convert.ToInt32(MyProductType) == (int)Atend.Control.Enum.ProductType.Cell) // { // CurrentCellObjectId = NewCellEntities; // } // else // { // CurrentCellEntities.Add(NewCellEntities); // } // } // Atend.Base.Acad.AT_INFO CellSubInfo = new Atend.Base.Acad.AT_INFO(NewCellEntities); // if (myCodeGuid != null) // { // CellSubInfo.ParentCode = NodeCode.ToString(); // CellSubInfo.NodeCode = myCodeGuid.ToString(); // } // else // { // CellSubInfo.ParentCode = myCodeGuid.ToString(); // CellSubInfo.NodeCode = ""; // } // if (MYProductCode != null) // { // CellSubInfo.ProductCode = Convert.ToInt32(MYProductCode); // } // else // { // CellSubInfo.ProductCode = 0; // } // if (MyProductType != null) // { // CellSubInfo.NodeType = Convert.ToInt32(MyProductType); // if (Convert.ToInt32(MyProductType) == (int)Atend.Control.Enum.ProductType.Bus) // { // CellSubInfo.ProductCode = Atend.Base.Equipment.EJAckPanel.AccessSelectByCode(ProductCode).MasterProductCode; // BusOIs.Add(NewCellEntities); // //ed.WriteMessage("Bus OI : {0}\n", NewCellEntities); // } // } // else // { // CellSubInfo.NodeType = 0; // } // CellSubInfo.Insert(); // } // if (CurrentCellObjectId != null && CurrentCellEntities.Count != 0) // { // foreach (ObjectId oi in CurrentCellEntities) // { // Atend.Base.Acad.AT_SUB.AddToAT_SUB(oi, CurrentCellObjectId); // } // } // } // #endregion // } // catch (System.Exception ex) // { // ed.WriteMessage("Error while drawing: {0} \n", ex.Message); // return; // } // } // //ed.WriteMessage("Bus Count : {0} \n", BusOIs.Count); // #region Join Buses to each other // foreach (Guid _ExistGuid in MyCells.Keys) // { // try // { // } // catch (System.Exception ex) // { // ed.WriteMessage("Error while Connect bus to each other: {0} \n", ex.Message); // return; // } // } // #endregion // //if (BusOIs.Count > 0) // //{ // // for (int BC = 0; BC < BusOIs.Count - 1; BC++) // // { // // Atend.Global.Acad.DrawEquips.AcDrawTerminal _AcDrawTerminal = new AcDrawTerminal(); // // _AcDrawTerminal.DrawTerminal(Atend.Global.Acad.UAcad.CenterOfEntity(Atend.Global.Acad.UAcad.GetEntityByObjectID(BusOIs[BC])), Atend.Global.Acad.UAcad.CenterOfEntity(Atend.Global.Acad.UAcad.GetEntityByObjectID(BusOIs[BC]))); // // //Atend.Base.Acad.AT_INFO BusInfo=new Atend.Base.Acad.AT_INFO( // // } // //} // #region Group all cells of Middlejack panel // if (NodeCode != Guid.Empty) // { // //ed.WriteMessage("Group all cells of Middlejack panel\n"); // ObjectId GroupOI = Atend.Global.Acad.Global.MakeGroup(NodeCode.ToString() + "-MJP", OIC); // Atend.Base.Acad.AT_INFO MiddleGroupInfo = new Atend.Base.Acad.AT_INFO(GroupOI); // MiddleGroupInfo.ParentCode = ParentCode.ToString(); // MiddleGroupInfo.NodeCode = NodeCode.ToString(); // MiddleGroupInfo.NodeType = (int)Atend.Control.Enum.ProductType.MiddleJackPanel; // MiddleGroupInfo.ProductCode = ProductCode; // MiddleGroupInfo.Insert(); // Atend.Base.Acad.AT_SUB.AddToAT_SUB(GroupOI, PostContainerEntity.ObjectId); // Atend.Base.Acad.AT_SUB.AddToAT_SUB(PostContainerEntity.ObjectId, GroupOI); // } // #endregion // #endregion // } // else // { // conti = false; // } // } //} public void DrawMiddleJackPanel(Entity PostContainerEntity, ref DataRow[] PostEquipInserted) { Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; bool conti = true; Guid NodeCode = new Guid(PostEquipInserted[0]["NodeCode"].ToString()); Guid ParentCode = new Guid(PostEquipInserted[0]["ParentCode"].ToString()); int ProductCode = Convert.ToInt32(PostEquipInserted[0]["ProductCode"]); Dictionary <Guid, List <Entity> > MyCells = new Dictionary <Guid, List <Entity> >(); double MyScale = Atend.Base.Design.DProductProperties.AccessSelectBySoftwareCode((int)Atend.Control.Enum.ProductType.MiddleJackPanel).Scale; DrawMiddleJackPanelJig MidJ = new DrawMiddleJackPanelJig(PostContainerEntity, MyScale); MidJ.MiddleJackPanelProductCode = ProductCode; MidJ.MiddleJaclPanelParentCode = ParentCode; MidJ.Cells = JackpanelCells; PromptResult pr; //ed.WriteMessage("------ START MJ {0} -------\n",NodeCode); while (conti) { pr = ed.Drag(MidJ); if (pr.Status == PromptStatus.OK) { conti = false; #region save data here ObjectIdCollection OIC = new ObjectIdCollection(); List <Guid> CellsGuid = new List <Guid>(); List <Entity> Entities = new List <Entity>(); Entities = MidJ.GetEntities(); //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #region Seprate different cells from each other //ed.WriteMessage("Seprate different cells from each other\n"); foreach (Entity ent in Entities) { Atend.Global.Acad.AcadJigs.MyPolyLine poly = ent as Atend.Global.Acad.AcadJigs.MyPolyLine; object CellCode = null; if (poly != null) { //ed.WriteMessage("~~~Poly~~~:{0}\n", poly.AdditionalDictionary.ContainsKey("ProductCode")); if (poly.AdditionalDictionary.ContainsKey("Code")) { poly.AdditionalDictionary.TryGetValue("Code", out CellCode); } } else { Atend.Global.Acad.AcadJigs.MyLine lin = ent as Atend.Global.Acad.AcadJigs.MyLine; if (lin != null) { if (lin.AdditionalDictionary.ContainsKey("Code")) { lin.AdditionalDictionary.TryGetValue("Code", out CellCode); } } else { Atend.Global.Acad.AcadJigs.MyCircle cir = ent as Atend.Global.Acad.AcadJigs.MyCircle; if (cir != null) { if (cir.AdditionalDictionary.ContainsKey("Code")) { cir.AdditionalDictionary.TryGetValue("Code", out CellCode); } } } } if (CellCode != null) { //ed.WriteMessage("Cellcode:{0}\n", CellCode); if (!MyCells.ContainsKey(new Guid(CellCode.ToString()))) { //ed.WriteMessage("\nCell Cuid Code:{0}\n", CellCode.ToString()); MyCells.Add(new Guid(CellCode.ToString()), new List <Entity>()); CellsGuid.Add(new Guid(CellCode.ToString())); List <Entity> Entities1; MyCells.TryGetValue(new Guid(CellCode.ToString()), out Entities1); Entities1.Add(ent); } else { List <Entity> Entities1; MyCells.TryGetValue(new Guid(CellCode.ToString()), out Entities1); Entities1.Add(ent); } } } #endregion //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ foreach (Guid _ExistGuid in MyCells.Keys) { try { #region Draw different cells //if (MyCells.ContainsKey(_ExistGuid)) //{ //ed.WriteMessage("Cell count : {0} \n", MyCells.Count); List <Entity> MyList = null; MyCells.TryGetValue(_ExistGuid, out MyList); if (MyList != null) { //ed.WriteMessage("~~~~~ Entities found ~~~~~\n"); ObjectIdCollection CurrentCellEntities = new ObjectIdCollection(); ObjectId CurrentCellObjectId = ObjectId.Null; foreach (Entity ent in MyList) { //----------------------- object MyProductType = null; object MYProductCode = null; object myCodeGuid = null; Atend.Global.Acad.AcadJigs.MyPolyLine poly = ent as Atend.Global.Acad.AcadJigs.MyPolyLine; if (poly != null) { //ed.WriteMessage("~~~POLY~~~{0}\n", poly.AdditionalDictionary.ContainsKey("ProductCode")); if (poly.AdditionalDictionary.ContainsKey("Code")) { poly.AdditionalDictionary.TryGetValue("Code", out myCodeGuid); } if (poly.AdditionalDictionary.ContainsKey("ProductType")) { poly.AdditionalDictionary.TryGetValue("ProductType", out MyProductType); } if (poly.AdditionalDictionary.ContainsKey("ProductCode")) { poly.AdditionalDictionary.TryGetValue("ProductCode", out MYProductCode); } } else { Atend.Global.Acad.AcadJigs.MyLine lin = ent as Atend.Global.Acad.AcadJigs.MyLine; if (lin != null) { if (lin.AdditionalDictionary.ContainsKey("Code")) { lin.AdditionalDictionary.TryGetValue("Code", out myCodeGuid); } if (lin.AdditionalDictionary.ContainsKey("ProductType")) { lin.AdditionalDictionary.TryGetValue("ProductType", out MyProductType); } if (lin.AdditionalDictionary.ContainsKey("ProductCode")) { lin.AdditionalDictionary.TryGetValue("ProductCode", out MYProductCode); } } else { Atend.Global.Acad.AcadJigs.MyCircle cir = ent as Atend.Global.Acad.AcadJigs.MyCircle; if (cir != null) { if (cir.AdditionalDictionary.ContainsKey("Code")) { cir.AdditionalDictionary.TryGetValue("Code", out myCodeGuid); } if (cir.AdditionalDictionary.ContainsKey("ProductType")) { cir.AdditionalDictionary.TryGetValue("ProductType", out MyProductType); } if (cir.AdditionalDictionary.ContainsKey("ProductCode")) { cir.AdditionalDictionary.TryGetValue("ProductCode", out MYProductCode); } } } } //------------------------ //ed.WriteMessage("Entity Type:{0}\n", ProductType); ObjectId NewCellEntities = Atend.Global.Acad.UAcad.DrawEntityOnScreen(ent, Atend.Control.Enum.AutoCadLayerName.MED_GROUND.ToString()); OIC.Add(NewCellEntities); // CurrentCellEntities.Add(NewCellEntities); if (MyProductType != null) { if (Convert.ToInt32(MyProductType) == (int)Atend.Control.Enum.ProductType.Cell) { CurrentCellObjectId = NewCellEntities; //ed.WriteMessage("CurrentCellObjectId was found\n"); } else { CurrentCellEntities.Add(NewCellEntities); } } //ed.WriteMessage("NodeCode : {0}\n", NodeCode); Atend.Base.Acad.AT_INFO CellSubInfo = new Atend.Base.Acad.AT_INFO(NewCellEntities); if (myCodeGuid != null) { //ed.WriteMessage("cell entity was found\n"); CellSubInfo.ParentCode = NodeCode.ToString(); //CurrentMiddleJackPanelCodeGuid.ToString(); CellSubInfo.NodeCode = myCodeGuid.ToString(); } else { CellSubInfo.ParentCode = myCodeGuid.ToString(); CellSubInfo.NodeCode = ""; } //ed.WriteMessage("2\n"); if (MYProductCode != null) { CellSubInfo.ProductCode = Convert.ToInt32(MYProductCode); } else { CellSubInfo.ProductCode = 0; } //ed.WriteMessage("3\n"); if (MyProductType != null) { CellSubInfo.NodeType = Convert.ToInt32(MyProductType); } else { CellSubInfo.NodeType = 0; } //ed.WriteMessage("4\n"); CellSubInfo.Insert(); } //insert cell sub //ed.WriteMessage("%%% CurrentCellObjectId %%% {0} : {1} \n", CurrentCellObjectId, CurrentCellEntities.Count); if (CurrentCellObjectId != null && CurrentCellEntities.Count != 0) { //ed.WriteMessage("5:1\n"); //Atend.Base.Acad.AT_SUB cellsub = new Atend.Base.Acad.AT_SUB(CurrentCellObjectId); foreach (ObjectId oi in CurrentCellEntities) { //cellsub.SubIdCollection.Add(oi); Atend.Base.Acad.AT_SUB.AddToAT_SUB(oi, CurrentCellObjectId); } //cellsub.Insert(); //ed.WriteMessage("5:2\n"); } } //} // ed.WriteMessage("One Pack Was drawn \n"); //} #endregion } catch (System.Exception ex) { ed.WriteMessage("Error while drawing: {0} \n", ex.Message); return; } } #region Group all cells of Middlejack panel if (NodeCode != null) { //ed.WriteMessage("Group all cells of Middlejack panel\n"); ObjectId GroupOI = Atend.Global.Acad.Global.MakeGroup(NodeCode.ToString() + "-MJP", OIC); Atend.Base.Acad.AT_INFO MiddleGroupInfo = new Atend.Base.Acad.AT_INFO(GroupOI); MiddleGroupInfo.ParentCode = ParentCode.ToString(); MiddleGroupInfo.NodeCode = NodeCode.ToString(); MiddleGroupInfo.NodeType = (int)Atend.Control.Enum.ProductType.MiddleJackPanel; MiddleGroupInfo.ProductCode = ProductCode; MiddleGroupInfo.Insert(); Atend.Base.Acad.AT_SUB.AddToAT_SUB(GroupOI, PostContainerEntity.ObjectId); } #endregion #endregion } else { conti = false; } } }
//~~~~~~~~~~~~~~~~~~~~~~~~~ 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 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; } } } }
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 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); }