public ObjectId GetSiteId(ObjectId surfaceId) { var site = ObjectId.Null; using (Transaction tr = CivilApplicationManager.StartTransaction()) { Autodesk.AutoCAD.DatabaseServices.Database db = CivilApplicationManager.WorkingDatabase; var doc = CivilDocument.GetCivilDocument(db); ObjectIdCollection siteIds = doc.GetSiteIds(); if (siteIds != null && siteIds.Count != 0) { site = (from s in siteIds.Cast <ObjectId>() select s).FirstOrDefault(); } if (site == ObjectId.Null) { site = C3DLandDb.Site.Create(doc, "Site-ALL"); } tr.Commit(); } return(site); }
public void SaveDrawingV3(List <Polyline3d> polyCollection, Autodesk.AutoCAD.DatabaseServices.Database sidedb) { var exfeaturelines = Commands.GetSurfaceEntityIDs(CivilApplicationManager.WorkingDatabase); ObjectIdCollection exfeatures = new ObjectIdCollection(exfeaturelines.ToArray()); using (Autodesk.AutoCAD.DatabaseServices.Database db = sidedb) { using (Transaction tr = db.TransactionManager.StartTransaction()) { BlockTable acBlkTbl; // Open the Block table for read acBlkTbl = tr.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable; // Open the Block table record Model space for write BlockTableRecord acBlkTblRec; acBlkTblRec = tr.GetObject(acBlkTbl[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord; IdMapping oIdMap = new IdMapping(); db.WblockCloneObjects( exfeatures, acBlkTblRec.ObjectId, oIdMap, DuplicateRecordCloning.Ignore, false); tr.Commit(); } db.SaveAs(Commands._drawingName, DwgVersion.Current); } }
public Breaklines(DateTime time, IList <string> listDwgs) { #region Assign Fields _time = time; _drawingName = ""; _listDwgs = new List <string>(listDwgs); _polylines = new List <Polyline3d>(); _originalPolys = new ObjectIdCollection(); #endregion }
public void AddStandardBreakline(ObjectId SurfaceId, ObjectId polyId, string name) { using (Transaction tr = CivilApplicationManager.StartTransaction()) { C3DLandDb.TinSurface surface = SurfaceId.GetObject(OpenMode.ForRead) as C3DLandDb.TinSurface; ObjectIdCollection entities = new ObjectIdCollection(); entities.Add(polyId); surface.BreaklinesDefinition.AddStandardBreaklines(entities, 1.0, 1.0, 1.0, 0.0); tr.Commit(); } }
ObjectIdCollection(string label, Autodesk.AutoCAD.DatabaseServices.ObjectId[] val) : base(label) { if (val.Length == 0) { m_val = new Autodesk.AutoCAD.DatabaseServices.ObjectIdCollection(); } else { m_val = new Autodesk.AutoCAD.DatabaseServices.ObjectIdCollection(val); } }
DrillDown() { if (m_val.Count > 0) { Autodesk.AutoCAD.DatabaseServices.ObjectIdCollection objIds = new Autodesk.AutoCAD.DatabaseServices.ObjectIdCollection(m_val.GetObjectIds()); using (TransactionHelper trHlp = new TransactionHelper(objIds[0].Database)) { trHlp.Start(); Snoop.Forms.DBObjects form = new Snoop.Forms.DBObjects(objIds, trHlp); form.ShowDialog(); trHlp.Commit(); } } }
DrillDown() { if (m_val.IsNull == false) { Autodesk.AutoCAD.DatabaseServices.ObjectIdCollection objIds = new Autodesk.AutoCAD.DatabaseServices.ObjectIdCollection(); objIds.Add(m_val); using (TransactionHelper trHlp = new TransactionHelper(m_val.Database)) { trHlp.Start(); Snoop.Forms.DBObjects form = new Snoop.Forms.DBObjects(objIds, trHlp); form.ShowDialog(); trHlp.Commit(); } } }
public void AddFeatureLinesToAllSurface(ObjectIdCollection featureIds, ObjectId surfaceId) { Debug.WriteLine("Starting AddFeatureLinesToAllSurface"); using (Application.DocumentManager.MdiActiveDocument.LockDocument()) { using (Transaction tr = CivilApplicationManager.StartTransaction()) { C3DLandDb.TinSurface surface = surfaceId.GetObject(OpenMode.ForRead) as C3DLandDb.TinSurface; surface.UpgradeOpen(); surface.BreaklinesDefinition.AddStandardBreaklines(featureIds, 1.0, 2.0, 2.0, 0.0); surface.DowngradeOpen(); tr.Commit(); Debug.WriteLine("Ending AddFeatureLinesToAllSurface"); } } }
ObjectIdCollection(string label, Autodesk.AutoCAD.DatabaseServices.ObjectIdCollection val) : base(label) { m_val = val; }
public static CadObjId[] GetViewportObjects(long vportnumber) { string sql = "SELECT * FROM pentity WHERE vportnumber =@vportnumber;"; Dictionary <string, object> parameters = new Dictionary <string, object>(); parameters.Add("vportnumber", vportnumber); DataTable dt = ExecuteQuery(sql, parameters); CadObjId cadobjid; CadObjIdCollection cadobjidls; long pobjid; int i = 0; string arraystring; int pc = dt.Rows.Count; string[] tokens;// = values.Split(','); long[] myItems; if (dt.Rows.Count > 0) { cadobjidls = new CadObjIdCollection(); arraystring = dt.Rows[0].Field <string>("mobjectid"); tokens = arraystring.Split(','); myItems = Array.ConvertAll <string, long>(tokens, long.Parse); foreach (long lid in myItems) { cadobjid = new CadObjId((IntPtr)lid); cadobjidls.Add(cadobjid); } CadObjId[] cabids = new CadObjId[cadobjidls.Count]; cadobjidls.CopyTo(cabids, 0); return(cabids); } else { return(null); } //string sql = "SELECT * FROM pentity WHERE vportnumber =@vportnumber;"; //Dictionary<string, object> parameters = new Dictionary<string, object>(); //parameters.Add("vportnumber", vportnumber); //DataTable dt = ExecuteQuery(sql, parameters); //CadObjId cadobjid; //CadObjIdCollection cadobjidls; //long pobjid,pid1; //int i = 0; //int pc = dt.Rows.Count; //if (dt.Rows.Count > 0) //{ // cadobjidls = new CadObjIdCollection(); // foreach (DataRow dr in dt.Rows) // { // pobjid = dr.Field<long>("mobjectid"); // cadobjid = new CadObjId((IntPtr)pobjid); // cadobjidls.Add(cadobjid); // } // return cadobjidls; // // pobjid= dt.Rows[0].Field<long>("mobjectid"); // ///pid1 = dt.Rows[1].Field<long>("mobjectid"); //} //else //return null; }