getAlignmentStyle(string name) { ObjectId idStyle = ObjectId.Null; AlignmentStyleCollection styles = BaseObjs._civDoc.Styles.AlignmentStyles; try { using (Transaction tr = BaseObjs.startTransactionDb()) { foreach (ObjectId id in styles) { AlignmentStyle style = (AlignmentStyle)tr.GetObject(id, OpenMode.ForRead); if (style.Name == name) { idStyle = style.ObjectId; } break; } tr.Commit(); } } catch (System.Exception ex) { BaseObjs.writeDebug(string.Format("{0} Align_Style.cs: line: 96", ex.Message)); } return(idStyle); }
jigLine(Point3d pnt3d, Polyline3d poly3d, int vertex) { ObjectId idPoly3d = ObjectId.Null; Editor ed = BaseObjs._editor; Point3dCollection pnts3d = new Point3dCollection { pnt3d, pnt3d }; Polyline3d ent = new Polyline3d(Poly3dType.SimplePoly, pnts3d, false); ent.TransformBy(ed.CurrentUserCoordinateSystem); Grading_JigPoly3d jig = new Grading_JigPoly3d(ent, poly3d, vertex); PromptResult res = ed.Drag(jig); if (res.Status == PromptStatus.OK) { Transaction tr = BaseObjs.startTransactionDb(); using (tr) { BlockTableRecord ms = Blocks.getBlockTableRecordMS(); idPoly3d = ms.AppendEntity(jig.Entity); tr.AddNewlyCreatedDBObject(jig.Entity, true); tr.Commit(); } } return(idPoly3d); }
getSectionStyleId(string name) { SectionStyleCollection styles = BaseObjs._civDoc.Styles.SectionStyles; try { using (Transaction tr = BaseObjs.startTransactionDb()) { foreach (ObjectId style in styles) { SectionStyle sStyle = (SectionStyle)tr.GetObject(style, OpenMode.ForRead); if (sStyle.Name == name) { return(sStyle.ObjectId); } } tr.Commit(); } } catch (System.Exception ex) { BaseObjs.writeDebug(string.Format("{0} Sect_Style.cs: line: 95", ex.Message)); } return(ObjectId.Null); }
addPntGroup(string nameGroup) { PointGroup pntGrp = null; try { using (Transaction tr = BaseObjs.startTransactionDb()) { if (_pointGroups.Contains(nameGroup)) { ObjectId grpId = _pointGroups[nameGroup]; pntGrp = (PointGroup)tr.GetObject(grpId, OpenMode.ForRead); } else { ObjectId grpId = _pointGroups.Add(nameGroup); pntGrp = (PointGroup)tr.GetObject(grpId, OpenMode.ForRead); } tr.Commit(); } } catch (System.Exception ex) { BaseObjs.writeDebug(string.Format("{0} Pnts.cs: line: 39", ex.Message)); } finally { } return(pntGrp); }
checkPntGroup(string nameGroup) { ObjectId id = getPntLabelStyle(nameGroup); PointGroup pntGrp; try { using (Transaction tr = BaseObjs.startTransactionDb()) { LabelStyle LS = (LabelStyle)tr.GetObject(id, OpenMode.ForRead); if (_pointGroups.Contains(nameGroup)) { ObjectId grpId = _pointGroups[nameGroup]; pntGrp = (PointGroup)tr.GetObject(grpId, OpenMode.ForWrite); } else { pntGrp = addPntGroup(nameGroup); } StandardPointGroupQuery query = new StandardPointGroupQuery(); query.IncludeNames = "SPNT*"; pntGrp.SetQuery(query); pntGrp.Update(); pntGrp.PointLabelStyleId = LS.ObjectId; tr.Commit(); } } catch (System.Exception ex) { BaseObjs.writeDebug(string.Format("{0} Pnts.cs: line: 90", ex.Message)); } }
removeProfile(ObjectId idAlign, string nameProfile) { ObjectId profileID = getProfileID(idAlign, nameProfile); if (profileID == ObjectId.Null) { return; } using (Transaction tr = BaseObjs.startTransactionDb()) { try { Profile profile = (Profile)tr.GetObject(profileID, OpenMode.ForWrite); if (profile != null) { profile.Erase(); } } catch (System.Exception ex) { BaseObjs.writeDebug(string.Format("{0} Prof.cs: line: 281", ex.Message)); } tr.Commit(); } }
AddPLObjEvent() { Database DB = BaseObjs._db; using (Transaction tr = BaseObjs.startTransactionDb()) { BlockTable BT = (BlockTable)tr.GetObject(DB.BlockTableId, OpenMode.ForRead); BlockTableRecord MS = (BlockTableRecord)tr.GetObject(BT[BlockTableRecord.ModelSpace], OpenMode.ForWrite); // Create a closed polyline POLY = new Polyline(); POLY.AddVertexAt(0, new Point2d(1, 1), 0, 0, 0); POLY.AddVertexAt(1, new Point2d(1, 2), 0, 0, 0); POLY.AddVertexAt(2, new Point2d(2, 2), 0, 0, 0); POLY.AddVertexAt(3, new Point2d(3, 3), 0, 0, 0); POLY.AddVertexAt(4, new Point2d(3, 2), 0, 0, 0); POLY.AddVertexAt(5, new Point2d(1, 1), 0, 0, 0); POLY.Closed = true; MS.AppendEntity(POLY); tr.AddNewlyCreatedDBObject(POLY, true); POLY.Modified += new EventHandler(POLY_Modified); POLY.Erased += new ObjectErasedEventHandler(POLY_Erased); tr.Commit(); } }
addSurfaceToSample(this ObjectId idSLG, ObjectIdCollection idsSurface) { try { using (Transaction tr = BaseObjs.startTransactionDb()) { SampleLineGroup group = (SampleLineGroup)tr.GetObject(idSLG, OpenMode.ForWrite); SectionSourceCollection sources = group.GetSectionSources(); foreach (SectionSource source in sources) { if (source.SourceType == SectionSourceType.TinSurface) { if (idsSurface.Contains(source.SourceId) == true) { source.IsSampled = true; } } } tr.Commit(); } } catch (System.Exception ex) { BaseObjs.writeDebug(string.Format("{0} Sect.cs: line: 71", ex.Message)); } }
CreateProfileStyle(string name) { CivilDocument civDoc = CivilApplication.ActiveDocument; ProfileStyleCollection profileStyles = civDoc.Styles.ProfileStyles; ObjectId idProfileStyle = ObjectId.Null; try { idProfileStyle = profileStyles.Add(name); } catch (System.Exception ex) { BaseObjs.writeDebug(string.Format("{0} Prof_Style.cs: line: 172", ex.Message)); } try { using (Transaction tr = BaseObjs.startTransactionDb()) { ProfileStyle oProfileStyle = (ProfileStyle)tr.GetObject(idProfileStyle, OpenMode.ForWrite); oProfileStyle.GetDisplayStyleProfile(ProfileDisplayStyleProfileType.Arrow).Visible = false; // set to yellow: oProfileStyle.GetDisplayStyleProfile(ProfileDisplayStyleProfileType.Line).Color = Color.FromColorIndex(ColorMethod.ByColor, 50); oProfileStyle.GetDisplayStyleProfile(ProfileDisplayStyleProfileType.Line).Visible = true; // grey oProfileStyle.GetDisplayStyleProfile(ProfileDisplayStyleProfileType.LineExtension).Color = Color.FromColorIndex(ColorMethod.ByColor, 251); oProfileStyle.GetDisplayStyleProfile(ProfileDisplayStyleProfileType.LineExtension).Visible = true; // green oProfileStyle.GetDisplayStyleProfile(ProfileDisplayStyleProfileType.Curve).Color = Color.FromColorIndex(ColorMethod.ByColor, 80); oProfileStyle.GetDisplayStyleProfile(ProfileDisplayStyleProfileType.Curve).Visible = true; // grey oProfileStyle.GetDisplayStyleProfile(ProfileDisplayStyleProfileType.ParabolicCurveExtension).Color = Color.FromColorIndex(ColorMethod.ByColor, 251); oProfileStyle.GetDisplayStyleProfile(ProfileDisplayStyleProfileType.ParabolicCurveExtension).Visible = true; // green oProfileStyle.GetDisplayStyleProfile(ProfileDisplayStyleProfileType.SymmetricalParabola).Color = Color.FromColorIndex(ColorMethod.ByColor, 81); oProfileStyle.GetDisplayStyleProfile(ProfileDisplayStyleProfileType.SymmetricalParabola).Visible = true; // green oProfileStyle.GetDisplayStyleProfile(ProfileDisplayStyleProfileType.AsymmetricalParabola).Color = Color.FromColorIndex(ColorMethod.ByColor, 83); oProfileStyle.GetDisplayStyleProfile(ProfileDisplayStyleProfileType.AsymmetricalParabola).Visible = true; // properties for 3D should also be set tr.Commit(); } } catch (System.Exception ex) { BaseObjs.writeDebug(string.Format("{0} Prof_Style.cs: line: 210", ex.Message)); } return(idProfileStyle); }
addSampleLineGroupAndSampleLines(this ObjectId idAlign, string name) { ObjectId idSLG = ObjectId.Null; try { using (Transaction tr = BaseObjs.startTransactionDb()) { Alignment align = (Alignment)tr.GetObject(idAlign, OpenMode.ForWrite); idSLG = SampleLineGroup.Create(name, idAlign); SampleLineGroup group = (SampleLineGroup)tr.GetObject(idSLG, OpenMode.ForWrite); Station[] stations = align.GetStationSet(StationTypes.All); foreach (Station station in stations) { ObjectId idSL = SampleLine.Create(string.Format("SL{0}", station.RawStation), idSLG, station.RawStation); SampleLine SL = (SampleLine)tr.GetObject(idSL, OpenMode.ForWrite); SL.StyleName = name; } tr.Commit(); } } catch (System.Exception ex) { BaseObjs.writeDebug(string.Format("{0} Sect.cs: line: 30", ex.Message)); } return(idSLG); }
addSections(this ObjectId idAlign, ObjectId idSLG, double offLeft, double offRight) { try { using (Transaction tr = BaseObjs.startTransactionDb()) { SampleLineGroup group = (SampleLineGroup)tr.GetObject(idSLG, OpenMode.ForWrite); foreach (ObjectId id in group.GetSampleLineIds()) { SampleLine SL = (SampleLine)tr.GetObject(id, OpenMode.ForRead); foreach (ObjectId idSection in SL.GetSectionIds()) { Section section = (Section)tr.GetObject(idSection, OpenMode.ForWrite); section.UpdateMode = SectionUpdateType.Dynamic; section.LeftSwathWidth = offLeft; section.RightSwathWidth = offRight; section.StyleName = section.Name; section.Layer = string.Format("{0}-SURFACE-SEC", section.Name); } } tr.Commit(); } } catch (System.Exception ex) { BaseObjs.writeDebug(string.Format("{0} Sect.cs: line: 50", ex.Message)); } }
setupSpreadSheetPS(string strFullPath, double dblHeight) { string strPath = BaseObjs.docFullName; string strJN = BaseObjs.jobNumber(); string strFN = string.Format("{0}EW.xlsx", strJN); string strPntX = "24"; string strPntY = "6"; string strPntIns = string.Format("{0},{1}", strPntX, strPntY); Excel_ext excl = new Excel_ext(true); excl.OpenFile(strFullPath, ""); excl.FindExcelWorksheet("SUMMARY"); Excel._Worksheet objWS = excl.excelWrkSht; objWS.Range["EW_SUMMARY"].Copy(); excl.excelAPP.Visible = false; BaseObjs._acadDoc.SendStringToExecute(string.Format("_pasteclip {0}\r", strPntIns), true, false, false); SelectionSet ss = BaseObjs._editor.SelectAll().Value; int k = ss.Count; ObjectId id = ss.GetObjectIds()[k - 1]; using (var tr = BaseObjs.startTransactionDb()){ Autodesk.AutoCAD.DatabaseServices.Ole2Frame objAcadOle = (Ole2Frame)tr.GetObject(id, OpenMode.ForWrite); objAcadOle.LockAspect = false; objAcadOle.WcsHeight = dblHeight; objAcadOle.WcsWidth = dblHeight / 2; tr.Commit(); } }
jigPolylineArea(Point3d pnt3dBase) { Database db = BaseObjs._db; Editor ed = BaseObjs._editor; Polyline poly = null; JigRect jgRect = new JigRect(pnt3dBase); ed.Drag(jgRect); using (Transaction tr = BaseObjs.startTransactionDb()) { BlockTableRecord btr = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite); poly = new Polyline(); poly.SetDatabaseDefaults(); for (int i = 0; i < jgRect.corners.Count - 1; i++) { Point3d pnt3d = jgRect.corners[i]; Point2d pnt2d = new Point2d(pnt3d.X, pnt3d.Y); poly.AddVertexAt(i, pnt2d, 0, db.Plinewid, db.Plinewid); } poly.Closed = true; poly.TransformBy(jgRect.UCS); btr.AppendEntity(poly); tr.AddNewlyCreatedDBObject(poly, true); tr.Commit(); } return(poly); }
copySectionStyle() { Document acDocTar = BaseObjs._acadDoc; // target - Active Document Database dbTar = acDocTar.Database; // target database Document acDocSrc = BaseObjs.openDwg("R:\\TSet\\Template\\CIVIL3D2010\\EW.dwt"); // source - Active Document Application.DocumentManager.MdiActiveDocument = acDocSrc; CivilDocument civDocSrc = BaseObjs._civDoc; SectionStyleCollection objSectionStyles = civDocSrc.Styles.SectionStyles; //source Section Styles using (Transaction tr = BaseObjs.startTransactionDb()) { foreach (ObjectId idStyle in objSectionStyles) { SectionStyle style = (SectionStyle)tr.GetObject(idStyle, OpenMode.ForRead); if (style.Name != "Standard") { style.ExportTo(dbTar, Autodesk.Civil.StyleConflictResolverType.Override); //export from source to target db } } tr.Commit(); } Application.DocumentManager.MdiActiveDocument = acDocTar; acDocSrc.CloseAndDiscard(); }
getProfileView(string nameAlign, string nameProfileView) { ProfileView profileview = null; try { using (Transaction tr = BaseObjs.startTransactionDb()) { ObjectId idAlign = Align.getAlignmentID(nameAlign); Alignment align = (Alignment)idAlign.GetObject(OpenMode.ForRead); ObjectIdCollection viewIDs = align.GetProfileViewIds(); foreach (ObjectId viewID in viewIDs) { ProfileView pv = (ProfileView)viewID.GetObject(OpenMode.ForRead); if (pv.Name == nameProfileView) { profileview = pv; break; } } tr.Commit(); } } catch (System.Exception ex) { BaseObjs.writeDebug(string.Format("{0} Prof.cs: line: 228", ex.Message)); } return(profileview); }
CreateProfileViewStyle(string name) { ObjectId idPVStyle = ObjectId.Null; ProfileViewStyleCollection pvStyleCol = BaseObjs._civDoc.Styles.ProfileViewStyles; try{ idPVStyle = pvStyleCol[name]; } catch {} if (!idPVStyle.IsNull) { return(idPVStyle); } idPVStyle = pvStyleCol.Add(name); using (var tr = BaseObjs.startTransactionDb()){ ProfileViewStyle pvStyle = (ProfileViewStyle)tr.GetObject(idPVStyle, OpenMode.ForWrite); AxisStyle axisStyle = pvStyle.BottomAxis; axisStyle.MajorTickStyle.Size = 0.01; axisStyle.MajorTickStyle.Interval = 50; axisStyle.TitleStyle.Text = "Stations"; axisStyle = pvStyle.TopAxis; axisStyle.TitleStyle.Text = "Feet"; tr.Commit(); } return(idPVStyle); }
getProfileViews() { ObjectIdCollection idAligns = BaseObjs._civDoc.GetAlignmentIds(); ObjectIdCollection idsPV = new ObjectIdCollection(); try { using (Transaction tr = BaseObjs.startTransactionDb()) { foreach (ObjectId id in idAligns) { Alignment align = (Alignment)tr.GetObject(id, OpenMode.ForRead); ObjectIdCollection viewIDs = align.GetProfileViewIds(); foreach (ObjectId viewID in viewIDs) { idsPV.Add(viewID); } } tr.Commit(); } } catch (System.Exception ex) { BaseObjs.writeDebug(string.Format("{0} Prof.cs: line: 228", ex.Message)); } return(idsPV); }
getProfileStyle(string name) { ObjectId idStyle = ObjectId.Null; CivilDocument civDoc = CivilApplication.ActiveDocument; try { using (Transaction tr = BaseObjs.startTransactionDb()) { ProfileStyleCollection styles = BaseObjs._civDoc.Styles.ProfileStyles; if (styles.Contains(name)) { idStyle = styles[name]; } else { idStyle = CreateProfileStyle(name); } tr.Commit(); } } catch (System.Exception ex) { BaseObjs.writeDebug(string.Format("{0} Prof_Style.cs: line: 250", ex.Message)); } return(idStyle); }
addProfileBySurface(string nameProfile, ObjectId idAlign, ObjectId idSurf, ObjectId idLayer, ObjectId idProfileStyle, ObjectId idLabelSet) { Profile profile = null; ObjectId id = ObjectId.Null; CivilDocument civDoc = BaseObjs._civDoc; try { using (Transaction tr = BaseObjs.startTransactionDb()) { try { profile = Prof.getProfile(idAlign, nameProfile); if (profile != null) { Prof.removeProfile(idAlign, nameProfile); } id = Profile.CreateFromSurface(nameProfile, idAlign, idSurf, idLayer, idProfileStyle, idLabelSet); } catch (System.Exception ex) { BaseObjs.writeDebug(string.Format("{0} Prof.cs: line: 45", ex.Message)); } profile = (Profile)tr.GetObject(id, OpenMode.ForWrite); tr.Commit(); } } catch (System.Exception ex) { BaseObjs.writeDebug(string.Format("{0} Prof.cs: line: 52", ex.Message)); } return(profile); }
ForEach <T>(Action <T> action) where T : Entity { try { using (var tr = BaseObjs.startTransactionDb()) { var blockTable = (BlockTable)tr.GetObject(BaseObjs._db.BlockTableId, OpenMode.ForRead); var modelSpace = (BlockTableRecord)tr.GetObject(blockTable[BlockTableRecord.ModelSpace], OpenMode.ForRead); RXClass theClass = RXObject.GetClass(typeof(T)); foreach (ObjectId id in modelSpace) { if (id.ObjectClass.IsDerivedFrom(theClass)) { try { var ent = (T)tr.GetObject(id, OpenMode.ForRead); action(ent); } catch (System.Exception ex) { BaseObjs.writeDebug(ex.Message + " LdrText_Misc.cs: line: 37"); } } } tr.Commit(); } } catch (System.Exception ex) { BaseObjs.writeDebug(ex.Message + " LdrText_Misc.cs: line: 46"); } }
getPntStyle(string namePntStyle) { PointStyle pntStyle = null; try { using (Transaction tr = BaseObjs.startTransactionDb()) { PointStyleCollection pntStyles = BaseObjs._civDoc.Styles.PointStyles; foreach (ObjectId id in pntStyles) { pntStyle = (PointStyle)tr.GetObject(id, OpenMode.ForRead); if (pntStyle.Name == namePntStyle) { return(pntStyle); } } ObjectId idx = pntStyles.Add(namePntStyle); pntStyle = (PointStyle)tr.GetObject(idx, OpenMode.ForRead); //pntStyle not defined } } catch (System.Exception ex) { BaseObjs.writeDebug(string.Format("{0} Pnts.cs: line: 159", ex.Message)); } return(pntStyle); }
makeSectionLabelStyles() { CivilDocument civDoc = BaseObjs._civDoc; LabelStyle objLabelStyle = null; using (var tr = BaseObjs.startTransactionDb()){ ObjectId idLabelStyle = civDoc.Styles.LabelStyles.SectionLabelStyles.MajorOffsetLabelStyles.Add("EW"); objLabelStyle = (LabelStyle)tr.GetObject(idLabelStyle, OpenMode.ForWrite); //Set objMajorStationSetItem = objSectionLabelStyleSet.MajorStationLabelSet.Add(objLabelStyle, 100#) idLabelStyle = civDoc.Styles.LabelStyles.SectionLabelStyles.MinorOffsetLabelStyles.Add("EW"); objLabelStyle = (LabelStyle)tr.GetObject(idLabelStyle, OpenMode.ForWrite); objLabelStyle.Properties.Label.Visibility.Value = false; //Set objMinorStationSetItem = objSectionLabelStyleSet.MinorStationLabelSet.Add(objLabelStyle, 50#, objMajorStationSetItem) idLabelStyle = civDoc.Styles.LabelStyles.SectionLabelStyles.GradeBreakLabelStyles.Add("EW"); objLabelStyle = (LabelStyle)tr.GetObject(idLabelStyle, OpenMode.ForWrite); objLabelStyle.Properties.Label.Visibility.Value = false; //Set objGradeBreakSetItem = objSectionLabelStyleSet.GradeBreaksLabelSet.Add(objLabelStyle) idLabelStyle = civDoc.Styles.LabelStyles.SectionLabelStyles.SegmentLabelStyles.Add("EW"); objLabelStyle = (LabelStyle)tr.GetObject(idLabelStyle, OpenMode.ForWrite); objLabelStyle.Properties.Label.Visibility.Value = false; //Set objSegmentSetItem = objSectionLabelStyleSet.SegmentLabelSet.Add(objLabelStyle) tr.Commit(); } }
updatePntGroup(string strGroupName) { try { using (Transaction tr = BaseObjs.startTransactionDb()) { try { if (_pointGroups.Contains(strGroupName)) { ObjectId grpId = _pointGroups[strGroupName]; PointGroup pntGrp = (PointGroup)tr.GetObject(grpId, OpenMode.ForWrite); pntGrp.Update(); } } catch (System.Exception ex) { BaseObjs.writeDebug(string.Format("{0} Pnts.cs: line: 281", ex.Message)); } tr.Commit(); } } catch (System.Exception ex) { BaseObjs.writeDebug(string.Format("{0} Pnts.cs: line: 287", ex.Message)); } }
addProfileView(ObjectId idAlign, Point3d pnt3dIns, ObjectId idProfileViewBandSet, ObjectId idProfileViewStyle) { ProfileView pview = null; try { using (Transaction tr = BaseObjs.startTransactionDb()) { Alignment align = (Alignment)tr.GetObject(idAlign, OpenMode.ForRead); //ObjectId id = ProfileView.Create(idAlign, pnt3dIns, align.Name, idProfileViewBandSet, idProfileViewStyle); ObjectId id = ProfileView.Create(BaseObjs._civDoc, idAlign.getAlignName(), idProfileViewBandSet, idAlign, pnt3dIns); pview = (ProfileView)tr.GetObject(id, OpenMode.ForWrite); pview.Layer = align.Layer; pview.StyleId = idProfileViewStyle; //pview.StationStart = align.StartingStation; //pview.StationEnd = align.EndingStation; tr.Commit(); } } catch (System.Exception ex) { BaseObjs.writeDebug(string.Format("{0} Prof.cs: line: 138", ex.Message)); } return(pview); }
getPntStyle(string namePntStyle) { PointStyle pntStyle = null; ObjectId idPntStyle = ObjectId.Null; try { using (Transaction tr = BaseObjs.startTransactionDb()) { PointStyleCollection pntStyles = BaseObjs._civDoc.Styles.PointStyles; foreach (ObjectId id in pntStyles) { pntStyle = (PointStyle)tr.GetObject(id, OpenMode.ForRead); if (pntStyle.Name == namePntStyle) { idPntStyle = pntStyle.ObjectId; break; } } if (idPntStyle == ObjectId.Null) { ObjectId idx = pntStyles.Add(namePntStyle); pntStyle = (PointStyle)tr.GetObject(idx, OpenMode.ForWrite); pntStyle.MarkerType = PointMarkerDisplayType.UsePointForMarker; idPntStyle = pntStyle.ObjectId; } tr.Commit(); } } catch (System.Exception ex) { BaseObjs.writeDebug(string.Format("{0} Pnt_Style.cs: line: 207", ex.Message)); } return(idPntStyle); }
getProfile(ObjectId idAlign, string nameProfile) { Profile profile = null; try { using (Transaction tr = BaseObjs.startTransactionDb()) { Alignment align = (Alignment)idAlign.GetObject(OpenMode.ForRead); ObjectIdCollection profileIDs = align.GetProfileIds(); foreach (ObjectId profileID in profileIDs) { Profile p = (Profile)profileID.GetObject(OpenMode.ForRead); if (p.Name == nameProfile) { profile = p; break; } } tr.Commit(); } } catch (System.Exception ex) { BaseObjs.writeDebug(string.Format("{0} Prof.cs: line: 183", ex.Message)); } return(profile); }
getGroupPlotStyle(string name) { GroupPlotStyleCollection styles = BaseObjs._civDoc.Styles.GroupPlotStyles; try { using (Transaction tr = BaseObjs.startTransactionDb()) { foreach (ObjectId style in styles) { GroupPlotStyle gStyle = (GroupPlotStyle)tr.GetObject(style, OpenMode.ForRead); if (gStyle.Name == name) { return(gStyle); } } tr.Commit(); } } catch (System.Exception ex) { BaseObjs.writeDebug(string.Format("{0} Sect_Style.cs: line: 27", ex.Message)); } return(null); }
getProfileID(ObjectId idAlign, string nameProfile) { ObjectId idProfile = ObjectId.Null; try { using (Transaction tr = BaseObjs.startTransactionDb()) { Alignment align = (Alignment)tr.GetObject(idAlign, OpenMode.ForRead); ObjectIdCollection profileIDs = align.GetProfileIds(); foreach (ObjectId id in profileIDs) { Profile profile = (Profile)tr.GetObject(id, OpenMode.ForRead); if (profile.Name == nameProfile) { idProfile = profile.ObjectId; break; } } tr.Commit(); } } catch (System.Exception ex) { BaseObjs.writeDebug(string.Format("{0} Prof.cs: line: 206", ex.Message)); } return(idProfile); }
getNestedPoints(BlockTableRecord Btr) { ObjectIdCollection ids = new ObjectIdCollection(); try { using (Transaction tr = BaseObjs.startTransactionDb()) { foreach (ObjectId idObj in Btr) { DBObject dbObj = tr.GetObject(idObj, OpenMode.ForRead); if (dbObj.GetType() == typeof(CogoPoint)) { ids.Add(dbObj.ObjectId); } } tr.Commit(); } } catch (System.Exception ex) { BaseObjs.writeDebug(string.Format("{0} Cogo.cs: line: 33", ex.Message)); } return(ids); }
private void t_Elapsed(object sender, ElapsedEventArgs e) { DBText txt = null; using (Transaction tr = BaseObjs.startTransactionDb()) { BlockTableRecord ms = Blocks.getBlockTableRecordMS(); cnt++; foreach (Vector3d v3d in v3ds) { txt = new DBText(); Point3d pX = pC.traverse(v3d.AngleOnPlane(pln), v3d.Length * (1 - 0.1 * i)); txt.SetDatabaseDefaults(); txt.TextString = "*"; txt.Position = pX; ids.Add(txt.ObjectId); ms.AppendEntity(txt); tr.AddNewlyCreatedDBObject(txt, true); ids.Add(txt.ObjectId); } tr.TransactionManager.QueueForGraphicsFlush(); tr.Commit(); } }