updateBrkLine(CogoPoint cogoPnt) { Database DB = BaseObjs._db; try { using (Transaction tr = BaseObjs.startTransactionDb()) { ResultBuffer RB = cogoPnt.GetXDataForApplication("lblBrks"); foreach (TypedValue TV in RB) { if (TV.TypeCode == 1005) { string strHandle = TV.Value.ToString(); long LN = Convert.ToInt64(strHandle, 16); Handle HN = new Handle(LN); ObjectId objID = DB.GetObjectId(false, HN, 0); Autodesk.AutoCAD.DatabaseServices.DBObject dbObj = tr.GetObject(objID, OpenMode.ForRead); BaseObjs._editor.WriteMessage(dbObj.Handle.ToString()); } } } } catch (System.Exception ex) { BaseObjs.writeDebug(ex.Message + " Mod.cs: line: 780"); } } //end updateBrkline
moveCogoPoint(this ObjectId idCgPnt, Point3d pnt3dTo) { Point3d pnt3dNew = Pub.pnt3dO; try { using (Transaction tr = BaseObjs.startTransactionDb()) { CogoPoint cgPnt = (CogoPoint)tr.GetObject(idCgPnt, OpenMode.ForWrite); Matrix3d matrx3d = BaseObjs._editor.CurrentUserCoordinateSystem; CoordinateSystem3d coordSys = matrx3d.CoordinateSystem3d; Point3d pnt3dFrom = idCgPnt.getCogoPntCoordinates(); Vector3d v3d = new Vector3d(pnt3dTo.X - pnt3dFrom.X, pnt3dTo.Y - pnt3dFrom.Y, 0); pnt3dNew = pnt3dFrom.TransformBy(Matrix3d.Displacement(v3d)); cgPnt.Easting = pnt3dNew.X; cgPnt.Northing = pnt3dNew.Y; } } catch (System.Exception ex) { BaseObjs.writeDebug(ex.Message + " Mod.cs: line: 554"); } }
moveSite(this ObjectIdCollection ids, Point3d pnt3dFrom, Point3d pnt3dTo) { Vector3d v3d = pnt3dFrom.GetVectorTo(pnt3dTo); try { using (Transaction tr = BaseObjs.startTransactionDb()) { foreach (ObjectId id in ids) { Entity ent = (Entity)tr.GetObject(id, OpenMode.ForWrite); if (ent is CogoPoint) { CogoPoint cgPnt = (CogoPoint)ent; Point3d cgPntLoc = id.getCogoPntCoordinates(); Point3d cgPntNew = cgPntLoc.TransformBy(Matrix3d.Displacement(v3d)); cgPnt.Easting = cgPntNew.X; cgPnt.Northing = cgPntNew.Y; } else { ent.TransformBy(Matrix3d.Displacement(v3d)); } } tr.Commit(); } } catch (System.Exception ex) { BaseObjs.writeDebug(ex.Message + " Mod.cs: line: 587"); } }
private void gotoPoint(Button btn) { Entity entX = null; using (BaseObjs._acadDoc.LockDocument()) { Handle h = btn.Content.ToString().stringToHandle(); entX = h.getEnt(); pnt = (CogoPoint)entX; Point3d pnt3dIns = pnt.Location; ViewTableRecord vtr = new ViewTableRecord(); vtr.CenterPoint = new Point2d(pnt3dIns.X, pnt3dIns.Y); vtr.Height = 30; vtr.Width = 50; BaseObjs._editor.SetCurrentView(vtr); pnt.Highlight(); BaseObjs.acadActivate(); ObjectId[] idsPntArr = new ObjectId[] { pnt.ObjectId }; List <ObjectId> idPnt = Base_Tools45.Select.getEntityatPoint(pnt3dIns, typeof(CogoPoint), "*"); ed.SelectionAdded += ed_SelectionAdded; proceed = true; } }
setOffsetPointMISC(Point3d dblPntX, string strLayer, string strDesc) { TypedValue[] tvs = new TypedValue[4] { new TypedValue(1001, "STAKE"), new TypedValue(1005, "0000"), new TypedValue(1070, -1), new TypedValue(1000, "MISC") }; uint pntNum = 0; double elev = System.Math.Round(dblPntX.Z, 3); Point3d pnt3d = new Point3d(dblPntX.X, dblPntX.Y, elev); ObjectId idCgPnt = pnt3d.setPoint("SPNT"); using (Transaction tr = BaseObjs.startTransactionDb()) { CogoPoint CgPnt = (CogoPoint)tr.GetObject(idCgPnt, OpenMode.ForWrite); CgPnt.LabelStyleId = Pnt_Style.getPntLabelStyle("SPNT"); pntNum = fStake.NextPntNum; CgPnt.PointName = string.Format("SPNT{0}", pntNum); CgPnt.RawDescription = strDesc; CgPnt.PointNumber = fStake.NextPntNum; fStake.NextPntNum++; tr.Commit(); } idCgPnt.setXData(tvs, "STAKE"); }
private void updateLbxAdd(ListBox lbx) { int n = lbx.Controls.Count; if (n == 0 || index == n) { return; } for (int i = index; i < n; i++) { Button btn = (Button)lbx.Controls[i]; System.Drawing.Point pnt = btn.Location; if (n > halfAdd) { if (i != halfAdd - 1) { pnt = new System.Drawing.Point(pnt.X, pnt.Y - (btnH + buf)); btn.Location = pnt; } else { pnt = new System.Drawing.Point(pnt.X - (btnW + buf), i * (btnH + buf)); btn.Location = pnt; } } else { pnt = new System.Drawing.Point(pnt.X, pnt.Y - (btnH + buf)); btn.Location = pnt; } } }
} // activateCogoPnts public static void deactivateCogoPnts(CogoPoint cogoPnt = null) { using (BaseObjs._acadDoc.LockDocument()) { using (Transaction TR = BaseObjs.startTransactionDb()) { if (cogoPnt == null) { TypedValue[] TVs = new TypedValue[1]; TVs.SetValue(new TypedValue((int)DxfCode.Start, "AECC_COGO_POINT"), 0); SelectionSet ss = Select.buildSSet(TVs); if (ss != null) { foreach (ObjectId id in ss.GetObjectIds()) { cogoPnt = (CogoPoint)TR.GetObject(id, OpenMode.ForWrite); if (cogoPnt != null) { cogoPnt.Modified -= new EventHandler(cogoPnt_Modified); cogoPnt.Erased -= new ObjectErasedEventHandler(cogoPnt_Erased); cogoPnts.Remove(cogoPnt.ObjectId); cogoPnts.TrimExcess(); } }// end foreach } } else { cogoPnt = (CogoPoint)cogoPnt.ObjectId.GetObject(OpenMode.ForWrite); cogoPnt.Modified -= new EventHandler(cogoPnt_Modified); cogoPnt.Erased -= new ObjectErasedEventHandler(cogoPnt_Erased); cogoPnts.Remove(cogoPnt.ObjectId); cogoPnts.TrimExcess(); } TR.Commit(); } } }// deactivateCogoPnts
private void updateLbxAdd(ListBox lbx) { int n = lbx.Items.Count; if (n == 0 || index == n) { return; } for (int i = index; i < n; i++) { Button btn = (Button)lbx.Items[i]; System.Windows.Point pnt = btn.PointToScreen(new System.Windows.Point(0, 0)); if (n > halfAdd) { if (i != halfAdd - 1) { System.Windows.Point pntx = new System.Windows.Point(pnt.X, pnt.Y - (btnH + buf)); //btn. = pntx; } else { System.Windows.Point pntx = new System.Windows.Point(pnt.X - (btnW + buf), i * (btnH + buf)); //btn.Location = pnt; } } else { pnt = new System.Windows.Point(pnt.X, pnt.Y - (btnH + buf)); //btn.Location = pnt; } } }
updatePntXData(CogoPoint cogoPnt, ObjectId idPoly3d) { try { checkPointXDataXNodes(cogoPnt, apps.lnkBrks); ResultBuffer RB0 = cogoPnt.ObjectId.getXData(apps.lnkBrks); Handle hPoly3d = idPoly3d.getHandle(); if (RB0 != null) { List <Handle> handles = RB0.rb_handles(); handles.Add(hPoly3d); cogoPnt.ObjectId.clearXData(apps.lnkBrks); cogoPnt.ObjectId.setXData(handles.handles_RB(apps.lnkBrks), apps.lnkBrks); } else { TypedValue[] tvs = new TypedValue[2]; tvs.SetValue(new TypedValue(1001, apps.lnkBrks), 0); tvs.SetValue(new TypedValue(1005, hPoly3d), 1); ResultBuffer RBX = new ResultBuffer(tvs); cogoPnt.ObjectId.setXData(tvs, apps.lnkBrks); } } catch (System.Exception ex) { BaseObjs.writeDebug(ex.Message + " Grading_xData.cs: line: 192"); } }
private void showLabelProperties(ObjectId pointId) { using (Transaction tr = startTransaction()) { CogoPoint point = pointId.GetObject(OpenMode.ForRead) as CogoPoint; showLabelPropertiesFor(point); } }
private uint getPointNumberFor(ObjectId pointId) { using (Transaction tr = startTransaction()) { CogoPoint point = pointId.GetObject(OpenMode.ForRead) as CogoPoint; return(point.PointNumber); } }
private void display(ObjectId pointId) { using (Transaction tr = startTransaction()) { CogoPoint point = pointId.GetObject(OpenMode.ForRead) as CogoPoint; displayPointInfo(point); } }
private void customizePoint(ObjectId id) { CogoPoint point = id.GetObject(OpenMode.ForWrite) as CogoPoint; point.SetUDPValue(_potable, true); point.SetUDPValue(_chloride, 150); point.SetUDPValue(_laboratory, "CivilDev Labs, Inc."); point.SetUDPValue(_hardness, "Carbonate (Temporary)"); point.SetUDPValue(_alkalinity, 7.5); }
private void displayPointInfo(CogoPoint point) { write("\nPoint Number: " + point.PointNumber.ToString()); write("\n- Location: " + point.Location.ToString()); write("\n- - Northing: " + point.Northing.ToString()); write("\n- - Easting: " + point.Easting.ToString()); write("\n- - Elevation: " + point.Elevation.ToString()); write("\n- Description: " + point.FullDescription); write("\n- Raw Description: " + point.RawDescription); }
AV() { ObjectId idPoly3d = Select.getBrkLine("\nSelect target breakline: "); CogoPoint cgPnt = CgPnt.selectPoint("\nSelect point to add to breakline: ", osMode: 8); cgPnt.ObjectId.updatePntXData(idPoly3d, apps.lnkBrks); Point3d pnt3d = cgPnt.ObjectId.getCogoPntCoordinates(); int numVertex = Geom.getVertexNo(idPoly3d, pnt3d); idPoly3d.addVertexToPoly3d(pnt3d, numVertex, cgPnt.Handle); }
deletePntDictionary() { Point3d pnt3dPicked = Pub.pnt3dO; Entity ent = Select.selectEntity(typeof(CogoPoint), "Select Cogo Point", "oops", out pnt3dPicked); CogoPoint cogoPnt = (CogoPoint)ent; bool exists = false; ObjectId idDictM = Dict.getNamedDictionary(apps.lnkBrks3, out exists); Dict.removeSubEntry(idDictM, cogoPnt.Handle.ToString()); }
private void showLabelPropertiesFor(CogoPoint point) { write("\nPoint Label Properties:"); write("\n- Style: " + getLabelStyleName(point.LabelStyleId)); write("\n- Style override: " + getLabelStyleName(point.LabelStyleIdOverride)); write("\n- Visible: " + point.IsLabelVisible.ToString()); write("\n- Location: " + point.LabelLocation.ToString()); write("\n- Rotation: " + point.LabelRotation.ToString()); write("\n- Dragged: " + point.IsLabelDragged.ToString()); write("\n- Pinned: " + point.IsLabelPinned.ToString()); }
setPointElevation(this ObjectId id, string result) { double elev = 0.0; double diff = 0.0; string optor = string.Empty; result = result.Trim(); string firstChar = result.Substring(0, 1); if (firstChar == "+" || firstChar == "-") { optor = result.Substring(0, 1); diff = double.Parse(result.Substring(1)); } else { double.TryParse(result.Substring(0), out elev); optor = "="; } CogoPoint pnt = null; Document doc = Application.DocumentManager.MdiActiveDocument; try { using (Transaction tr = doc.TransactionManager.StartTransaction()) { pnt = (CogoPoint)tr.GetObject(id, OpenMode.ForWrite); switch (optor) { case "=": pnt.Elevation = elev; break; case "+": pnt.Elevation = pnt.Elevation + diff; break; case "-": pnt.Elevation = pnt.Elevation - diff; break; } tr.Commit(); } } catch (System.Exception ex) { BaseObjs.writeDebug(string.Format("{0} Pnts.cs: line: 200", ex.Message)); } return(pnt.Elevation); }
selectCogoPntAtPoint3d(Point3d pnt3d) { Autodesk.AutoCAD.DatabaseServices.Entity ENT = null; Point3d pnt3d0 = new Point3d(pnt3d.X, pnt3d.Y, 0); CogoPoint cogoPnt = null; ObjectId idCgPnt = ObjectId.Null; try { using (Transaction tr = BaseObjs.startTransactionDb()) { TypedValue[] TVs = new TypedValue[1]; TVs.SetValue(new TypedValue((int)DxfCode.Start, "AECC_COGO_POINT"), 0); SelectionFilter FILTER = new SelectionFilter(TVs); PromptSelectionResult PSR = BaseObjs._editor.SelectCrossingWindow(pnt3d0, pnt3d0, FILTER); if (PSR.Status == PromptStatus.OK) { SelectionSet SS = PSR.Value; if (SS.Count > 1) { Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog(string.Format("{0} Points Found at Selected Location - Exiting....", SS.Count.ToString())); tr.Commit(); return(idCgPnt); } SelectedObject OBJ = SS[0]; if (OBJ != null) { ENT = tr.GetObject(OBJ.ObjectId, OpenMode.ForRead) as Autodesk.AutoCAD.DatabaseServices.Entity; } if (ENT != null) { if (ENT is CogoPoint) { cogoPnt = (CogoPoint)ENT; idCgPnt = cogoPnt.ObjectId; tr.Commit(); } } } } } catch (System.Exception ex) { BaseObjs.writeDebug(ex.Message + " Select.cs: line: 454"); } return(idCgPnt); }
public static bool IsSurveyPoint(ObjectId oid) { //open the COGO Point using (var trans = Active.Active.StartTransaction()) { CogoPoint cogoPoint = trans.GetObject(oid, OpenMode.ForRead) as CogoPoint; // Access COGO Point Properties // CogoPoint.IsSurveyPoint property indicates whether this Cogo Point is a Survey Point if (cogoPoint == null) { return(false); } if (cogoPoint.IsSurveyPoint) { // DO your stuff ed.WriteMessage("\nSelected COGO Point is a Survey Point"); return(true); } // CogoPoint.IsProjectPoint property indicates whether the CogoPoint is a project point // i.e. if the COGO point is from Vault Project Points else if (cogoPoint.IsProjectPoint) { // DO your stuff ed.WriteMessage("\nSelected COGO Point is a Project Point"); return(true); } // normal COGO point object created in the Civil 3D drawing file else { // DO your stuff ed.WriteMessage("\nSelected COGO Point is neither Survey nor Project Point"); return(false); } trans.Commit(); } }
public static Dictionary <string, object> geolocationCapture(CogoPointCollection passedCogoCollection) { var doc = Application.DocumentManager.MdiActiveDocument; var acDB = doc.Database; // Creat a json file of the Corner Record Points found in the CogoPointCollection // Retrieves the Long/Lat of the Point and converts to decimal degrees // Confirms that the Name field is filled correctly (cr x) using (var trans = acDB.TransactionManager.StartTransaction()) { Dictionary <string, object> cogoPointJson = new Dictionary <string, object>(); foreach (ObjectId cogoPointRecord in passedCogoCollection) { CogoPoint cogoPointItem = trans.GetObject(cogoPointRecord, OpenMode.ForRead) as CogoPoint; Match cogoMatch = Regex.Match(cogoPointItem.PointName, "^(\\s*cr\\s*\\d\\d*)$", RegexOptions.IgnoreCase); if (cogoMatch.Success) { Dictionary <String, object> cogoPointGeolocation = new Dictionary <string, object>(); //convert the Lat/Long from Radians to Decimal Degrees double rad2DegLong = (cogoPointItem.Longitude * 180) / Math.PI; double rad2DegLat = (cogoPointItem.Latitude * 180) / Math.PI; cogoPointGeolocation.Add("Corner_Type_c", "Other"); cogoPointGeolocation.Add("Geolocation_Longitude_s", rad2DegLong); cogoPointGeolocation.Add("Geolocation_Latitude_s", rad2DegLat); cogoPointGeolocation.Add("Full Description", cogoPointItem.FullDescription); cogoPointJson.Add(cogoPointItem.PointName.Trim().ToString().ToLower().Replace(" ", ""), cogoPointGeolocation); } } using (var writer = File.CreateText("CogoPointsGeolocation.json")) { string strResultJson = JsonConvert.SerializeObject(cogoPointJson, Formatting.Indented); writer.WriteLine(strResultJson); } trans.Commit(); return(cogoPointJson); } }
SelectPntsByRange(string strOption = "") { TypedValue[] tvs = new TypedValue[1]; tvs.SetValue(new TypedValue((int)DxfCode.Start, RXClass.GetClass(typeof(CogoPoint)).DxfName), 0); SelectionSet ss = Select.buildSSet(tvs); ObjectId[] ids = ss.GetObjectIds(); if (ids.Length == 0) { return; } List <CgPnt> cgPnts = new List <CgPnt>(); for (int i = 0; i < ids.Length; i++) { ObjectId idCgPnt = ids[i]; CogoPoint objPnt = (CogoPoint)idCgPnt.getEnt(); if (objPnt.Layer.Contains("-OS-")) { if (!objPnt.Layer.Contains("NOT-USED")) { ResultBuffer rb = idCgPnt.getXData("STAKE"); if (rb == null) { continue; } TypedValue[] tvs1 = rb.AsArray(); CgPnt cgPnt = new CgPnt { Num = objPnt.PointNumber, Desc = conformPntDesc(objPnt.RawDescription), nameLayer = objPnt.Layer, hAlign = tvs1[1].Value.ToString().stringToHandle() }; cgPnts.Add(cgPnt); } } } if (strOption == "") { strOption = "ByRange"; } Stake_ProcessPntList.ProcPntList(cgPnts, strOption); }
public void dragLabel() { Document acadDoc = Application.DocumentManager.MdiActiveDocument; CivilDocument civDoc = CivilApplication.ActiveDocument; SelectionSet ss = selectPoints("\nSelect Points on Screen."); ObjectId[] ids = ss.GetObjectIds(); using (Transaction TR = acadDoc.Database.TransactionManager.StartTransaction()) { foreach (ObjectId id in ids) { CogoPoint pnt = (CogoPoint)TR.GetObject(id, OpenMode.ForWrite); } } }
[CommandMethod("gsi")] //Comanda revizuita care importa puncte din fisiere gsi public void ImportGSI() { //Selectia fisierelor gsi Document acadDoc = Application.DocumentManager.MdiActiveDocument; CivilDocument civilDoc = CivilApplication.ActiveDocument; Editor ed = acadDoc.Editor; Database db = HostApplicationServices.WorkingDatabase; PromptOpenFileOptions POFO = new PromptOpenFileOptions("Select gsi file: "); POFO.Filter = ".gsi"; PromptFileNameResult FileRes = ed.GetFileNameForOpen(POFO); if (FileRes.Status != PromptStatus.OK) { ed.WriteMessage("\nFile selection failed! Aborting."); return; } string cale = FileRes.StringResult; PromptResult PSR = ed.GetString("\nSpecify points description"); if (PSR.Status != PromptStatus.OK) { ed.WriteMessage("\nInvalid description! Aborting."); return; } string descriere = PSR.StringResult; String3D listaPuncte = new String3D(); listaPuncte.ImportGSI(cale); using (Transaction trans = db.TransactionManager.StartTransaction()) { CogoPointCollection cogoPoints = civilDoc.CogoPoints; foreach (Punct3D punct in listaPuncte) { ObjectId pointId = cogoPoints.Add(new Point3d(punct.X, punct.Y, punct.Z)); CogoPoint cogo = pointId.GetObject(OpenMode.ForWrite) as CogoPoint; cogo.RawDescription = descriere; } trans.Commit(); } }
replacePntXData(CogoPoint cogoPnt, CogoPoint cogoPntX, Polyline3d poly3d) { try { ResultBuffer RB0 = poly3d.ObjectId.getXData(apps.lnkBrks); List <Handle> handles = RB0.rb_handles(); //get list of unique non Zero handles int i = handles.IndexOf(cogoPnt.Handle); handles.RemoveAt(i); handles.Insert(i, cogoPntX.Handle); poly3d.ObjectId.clearXData(apps.lnkBrks); poly3d.ObjectId.setXData(handles.handles_RB(apps.lnkBrks), apps.lnkBrks3); } catch (System.Exception ex) { BaseObjs.writeDebug(ex.Message + " Grading_xData.cs: line: 166"); } }
public static void EditCogoPoints() { Editor ed = Active.Active.Editor; // Select the location for COGO Point PromptPointOptions ppo = new PromptPointOptions("\nSelect the location to Create a COGO Point :"); PromptPointResult ppr = ed.GetPoint(ppo); if (ppr.Status != PromptStatus.OK) { return; } Point3d location = ppr.Value; //start a transaction using (Transaction trans = Active.Active.StartTransaction()) { // All points in a document are held in a CogoPointCollection object // We can access CogoPointCollection through the CivilDocument.CogoPoints property CogoPointCollection cogoPoints = CivilApplication.ActiveDocument.CogoPoints; // Adds a new CogoPoint at the given location with the specified description information ObjectId pointId = cogoPoints.Add(location, "Survey Point", true); CogoPoint cogoPoint = pointId.GetObject(OpenMode.ForWrite) as CogoPoint; // Set Some Properties if (cogoPoint != null) { cogoPoint.PointName = "Survey_Base_Point"; cogoPoint.RawDescription = "This is Survey Base Point"; } trans.Commit(); } }
checkPointXDataXNodes(CogoPoint cogoPnt, string nameApp) { try { ResultBuffer RB0 = cogoPnt.ObjectId.getXData(nameApp); if (RB0 != null) { List <Handle> handles = RB0.rb_handles(); Handle h = "0".stringToHandle(); ObjectId id = ObjectId.Null; int k = handles.Count; for (int i = k - 1; i > -1; i--) { try { h = handles[i]; id = h.getObjectId(); if (!id.IsValid || id.IsErased || id.IsEffectivelyErased) { handles.RemoveAt(i); continue; } } catch (System.Exception ex) { handles.RemoveAt(i); } Polyline3d poly3d = (Polyline3d)h.getEnt(); if (poly3d == null) { handles.RemoveAt(i); } } cogoPnt.ObjectId.clearXData(nameApp); cogoPnt.ObjectId.setXData(handles.handles_RB(nameApp), nameApp); } } catch (System.Exception ex) { BaseObjs.writeDebug(ex.Message + " Grading_xData.cs: line: 107"); } }
activatecogoPnts(CogoPoint cogoPnt1 = null) { Editor ED = BaseObjs._editor; using (Transaction tr = BaseObjs.startTransactionDb()) { if (cogoPnt1 == null) { TypedValue[] TVs = new TypedValue[1]; TVs.SetValue(new TypedValue((int)DxfCode.Start, "AECC_COGO_POINT"), 0); SelectionFilter SF = new SelectionFilter(TVs); PromptSelectionResult PSR = ED.SelectAll(SF); if (PSR.Status == PromptStatus.OK) { SelectionSet SS = PSR.Value; foreach (SelectedObject OBJ in SS) { if (OBJ != null) { cogoPnt = (CogoPoint)tr.GetObject(OBJ.ObjectId, OpenMode.ForWrite); cogoPnt.Modified += new EventHandler(cogoPnt_Modified); cogoPnt.Erased += new ObjectErasedEventHandler(cogoPnt_Erased); cogoPnts.Add(cogoPnt.ObjectId); cogoPnts.TrimExcess(); } } // end foreach } // end if } else { cogoPnt = (CogoPoint)tr.GetObject(cogoPnt1.ObjectId, OpenMode.ForWrite); cogoPnt.Modified += new EventHandler(cogoPnt_Modified); cogoPnt.Erased += new ObjectErasedEventHandler(cogoPnt_Erased); } tr.Commit(); } // end using } // activatecogoPnts
}// activateCogoPnts /// <summary> /// /// </summary> /// <param name="cogoPnt"></param> public static void deactivateCogoPnts(CogoPoint cogoPnt = null) { try { using (Transaction tr = BaseObjs.startTransactionDb()) { if (cogoPnt == null) { TypedValue[] TVs = new TypedValue[1]; TVs.SetValue(new TypedValue((int)DxfCode.Start, "AECC_COGO_POINT"), 0); SelectionSet SS = Base_Tools45.Select.buildSSet(TVs); foreach (ObjectId id in SS.GetObjectIds()) { cogoPnt = (CogoPoint)tr.GetObject(id, OpenMode.ForWrite); if (cogoPnt != null) { cogoPnt.Modified -= new EventHandler(cogoPnt_Modified); cogoPnt.Erased -= new ObjectErasedEventHandler(cogoPnt_Erased); cogoPnts.Add(cogoPnt.ObjectId); cogoPnts.TrimExcess(); } }// end foreach } else { cogoPnt = (CogoPoint)cogoPnt.ObjectId.GetObject(OpenMode.ForWrite); cogoPnt.Modified -= new EventHandler(cogoPnt_Modified); cogoPnt.Erased -= new ObjectErasedEventHandler(cogoPnt_Erased); cogoPnts.Add(cogoPnt.ObjectId); cogoPnts.TrimExcess(); } tr.Commit(); } } catch (System.Exception ex) { BaseObjs.writeDebug(ex.Message + " Events.cs: line: 280"); } }// deactivateCogoPnts
[CommandMethod("convacadpts")] //Comanda pentru convertirea punctelor autocad in puncte COGO de civil3d public void ConvAcadPts() { CivilDocument civDoc = CivilApplication.ActiveDocument; Database db = HostApplicationServices.WorkingDatabase; Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; //Selectia punctelor autocad PromptSelectionOptions PrSelOpt = new PromptSelectionOptions(); PrSelOpt.MessageForAdding = "\nSelect points to add: "; PrSelOpt.MessageForRemoval = "\nSelect points to remove: "; TypedValue[] tvs = { new TypedValue((int)DxfCode.Start, "POINT") }; SelectionFilter sf = new SelectionFilter(tvs); PromptSelectionResult PrSelRes = ed.GetSelection(PrSelOpt, sf); if (PrSelRes.Status != PromptStatus.OK) { ed.WriteMessage("\nInvalid Selection! Aborting."); return; } //Solicitarea descrierii punctelor COGO string descriere = ed.GetString("\nSpecify points description: ").StringResult; //Creearea puntelor COGO using (Transaction trans = db.TransactionManager.StartTransaction()) { CogoPointCollection cogoPoints = civDoc.CogoPoints; foreach (SelectedObject selObj in PrSelRes.Value) { Autodesk.AutoCAD.DatabaseServices.DBPoint punctAcad = (Autodesk.AutoCAD.DatabaseServices.DBPoint)trans.GetObject(selObj.ObjectId, OpenMode.ForRead); ObjectId pointId = cogoPoints.Add(punctAcad.Position); CogoPoint cogo = pointId.GetObject(OpenMode.ForWrite) as CogoPoint; cogo.RawDescription = descriere; } trans.Commit(); } }