addPointNumberComponent(LabelStyle style) { ObjectId id = style.AddComponent("PN", LabelStyleComponentType.Text); LabelStyleTextComponent textComp = (LabelStyleTextComponent)id.GetObject(OpenMode.ForWrite); textComp.Text.Attachment.Value = LabelTextAttachmentType.BottomLeft; textComp.Text.Contents.Value = _pointNumber; textComp.General.AnchorComponent.Value = "Z"; textComp.General.AnchorLocation.Value = AnchorPointType.TopLeft; }
addLocationZcomponent(LabelStyle style) { ObjectId id = style.AddComponent("Z", LabelStyleComponentType.Text); LabelStyleTextComponent textComp = (LabelStyleTextComponent)id.GetObject(OpenMode.ForWrite); textComp.Text.Attachment.Value = LabelTextAttachmentType.MiddleLeft; textComp.Text.Contents.Value = _elevation; //textComp.General.AnchorComponent.Value = ******defaults to <Feature> when value is unassigned************* textComp.General.AnchorLocation.Value = AnchorPointType.MiddleRight; }
private void addPointNumberComponent(LabelStyle style) { ObjectId id = style.AddComponent("PN", LabelStyleComponentType.Text); LabelStyleTextComponent component = id.GetObject(OpenMode.ForWrite) as LabelStyleTextComponent; component.Text.Attachment.Value = LabelTextAttachmentType.MiddleLeft; //component.Text.Contents.Value = _pointNumber; component.General.AnchorComponent.Value = "Leader"; component.General.AnchorLocation.Value = AnchorPointType.End; }
addLocationXYcomponent(LabelStyle style) { ObjectId id = style.AddComponent("XY", LabelStyleComponentType.Text); LabelStyleTextComponent textComp = (LabelStyleTextComponent)id.GetObject(OpenMode.ForWrite); textComp.Text.Attachment.Value = LabelTextAttachmentType.TopLeft; string value = string.Format("(X={0}, Y={1}, Z={2})", _easting, _northing, _elevation); textComp.Text.Contents.Value = value; textComp.General.AnchorComponent.Value = "DESC"; textComp.General.AnchorLocation.Value = AnchorPointType.BottomLeft; }
private void addLocationComponent(LabelStyle style) { ObjectId id = style.AddComponent("Location", LabelStyleComponentType.Text); LabelStyleTextComponent component = id.GetObject(OpenMode.ForWrite) as LabelStyleTextComponent; component.Text.Attachment.Value = LabelTextAttachmentType.TopLeft; //string value = String.Format("({0}, {1}, {2})", _northing, _easting, _elevation); //component.Text.Contents.Value = value; component.General.AnchorComponent.Value = "PN"; component.General.AnchorLocation.Value = AnchorPointType.BottomLeft; }
getPntLabelStyle(string name) { LabelStyle LS = null; ObjectId id = ObjectId.Null; try { using (Transaction tr = BaseObjs.startTransactionDb()) { LabelStyleCollection labelStyles = BaseObjs._civDoc.Styles.LabelStyles.PointLabelStyles.LabelStyles; if (labelStyles.Contains(name)) { LS = (LabelStyle)tr.GetObject(labelStyles[name], OpenMode.ForRead); return(LS.ObjectId); } else { Base_Tools45.Layer.manageLayers(name); TextStyleTableRecord TStr = Base_Tools45.Txt.getTextStyleTableRecord("L100"); if (TStr == null) { TStr = Base_Tools45.Txt.addTextStyleTableRecord("L100"); } TStr.FileName = "ROMANS"; TStr.XScale = 0.8; CivilDocument civDoc = CivilApplication.ActiveDocument; id = civDoc.Styles.LabelStyles.PointLabelStyles.LabelStyles.Add(name); LS = (LabelStyle)tr.GetObject(id, OpenMode.ForWrite); LS.AddComponent("PointNumber", LabelStyleComponentType.Text); ObjectIdCollection ids = LS.GetComponents(LabelStyleComponentType.Text); LabelStyleTextComponent lstc1 = (LabelStyleTextComponent)tr.GetObject(ids[0], OpenMode.ForWrite); lstc1.General.Visible.Value = true; LS.Properties.DraggedStateComponents.DisplayType.Value = Autodesk.Civil.LabelContentDisplayType.StackedText; tr.Commit(); } } } catch (System.Exception ex) { BaseObjs.writeDebug(string.Format("{0} Pnts.cs: line: 133", ex.Message)); } return(id); }
CreateProfileViewBandSetStyle(string name) { string PROFILEVIEW_BANDSET_STYLE_NAME = name; string PROFILEVIEW_PROFILE_BAND_STYLE_NAME = name; ObjectId idPVBandSetStyle = ObjectId.Null; ProfileViewBandSetStyleCollection pvBandSetStyleCol = BaseObjs._civDoc.Styles.ProfileViewBandSetStyles; try{ idPVBandSetStyle = pvBandSetStyleCol[PROFILEVIEW_BANDSET_STYLE_NAME]; } catch {} if (!idPVBandSetStyle.IsNull) { return(idPVBandSetStyle); } idPVBandSetStyle = BaseObjs._civDoc.Styles.ProfileViewBandSetStyles.Add(PROFILEVIEW_BANDSET_STYLE_NAME); using (var tr = BaseObjs.startTransactionDb()){ ProfileViewBandSetStyle pvBandSetStyle = (ProfileViewBandSetStyle)tr.GetObject(idPVBandSetStyle, OpenMode.ForWrite); ObjectId id = ObjectId.Null; try{ id = BaseObjs._civDoc.Styles.BandStyles.ProfileViewProfileDataBandStyles[PROFILEVIEW_PROFILE_BAND_STYLE_NAME]; } catch {} if (!id.IsNull) { return(idPVBandSetStyle); } id = BaseObjs._civDoc.Styles.BandStyles.ProfileViewProfileDataBandStyles.Add(PROFILEVIEW_PROFILE_BAND_STYLE_NAME); ProfileDataBandStyle pDataBandStyle = (ProfileDataBandStyle)tr.GetObject(id, OpenMode.ForWrite); DisplayStyle displayStyle = pDataBandStyle.GetDisplayStylePlan(ProfileDataDisplayStyleType.LabelsAtVGP); displayStyle.Visible = true; displayStyle = pDataBandStyle.GetDisplayStylePlan(ProfileDataDisplayStyleType.TicksAtHGP); displayStyle.Color = clr.red; displayStyle.Visible = true; id = pDataBandStyle.HGPLabelStyleId; LabelStyle labelStyle = (LabelStyle)tr.GetObject(id, OpenMode.ForWrite); ObjectIdCollection ids = labelStyle.GetComponents(LabelStyleComponentType.Text); id = ids[0]; LabelStyleTextComponent labelStyleText = (LabelStyleTextComponent)tr.GetObject(id, OpenMode.ForWrite); labelStyleText.Text.Contents.Value = "<[Station Value(Uft|FS|P0|RN|AP|Sn|TP|B2|EN|W0|OF)]>"; labelStyleText.Text.Color.Value = clr.c11; displayStyle = pDataBandStyle.GetDisplayStylePlan(ProfileDataDisplayStyleType.TitleBox); displayStyle.Color = clr.red; displayStyle.Linetype = "ByBlock"; displayStyle.Visible = true; displayStyle = pDataBandStyle.GetDisplayStylePlan(ProfileDataDisplayStyleType.TitleBoxText); displayStyle.Color = clr.grn; displayStyle.Visible = true; id = pDataBandStyle.TitleTextLabelStyleId; labelStyle = (LabelStyle)tr.GetObject(id, OpenMode.ForWrite); ids = labelStyle.GetComponents(LabelStyleComponentType.Text); id = ids[0]; labelStyleText = (LabelStyleTextComponent)tr.GetObject(id, OpenMode.ForWrite); labelStyleText.Text.Contents.Value = "Profile Data: XX"; labelStyleText.Text.Height.Value = 0.09; pDataBandStyle.GetDisplayStylePlan(ProfileDataDisplayStyleType.MajorStationLabel).Visible = false; pDataBandStyle.GetDisplayStylePlan(ProfileDataDisplayStyleType.MajorTicks).Visible = false; pDataBandStyle.GetDisplayStylePlan(ProfileDataDisplayStyleType.MinorStationLabel).Visible = false; pDataBandStyle.GetDisplayStylePlan(ProfileDataDisplayStyleType.MinorTicks).Visible = false; pDataBandStyle.GetDisplayStylePlan(ProfileDataDisplayStyleType.TicksAtVGP).Visible = false; pDataBandStyle.GetDisplayStylePlan(ProfileDataDisplayStyleType.TicksAtStationEquations).Visible = false; pDataBandStyle.GetDisplayStylePlan(ProfileDataDisplayStyleType.LabelsAtVGP).Visible = false; pDataBandStyle.GetDisplayStylePlan(ProfileDataDisplayStyleType.LabelsAtStationEquations).Visible = false; pvBandSetStyle.GetBottomBandSetItems().Add(BaseObjs._db, Autodesk.Civil.BandType.ProfileData, PROFILEVIEW_PROFILE_BAND_STYLE_NAME); } return(idPVBandSetStyle); }
createAlignLabelSetStyle(string name) { AlignmentLabelSetStyle alignLabelSetStyle = null; ObjectId idStyle = ObjectId.Null; ObjectId idItem = ObjectId.Null; try { idStyle = BaseObjs._civDoc.Styles.LabelSetStyles.AlignmentLabelSetStyles[name]; } catch (System.Exception ex) { BaseObjs.writeDebug(string.Format("{0} Align_Style.cs: line: 112", ex.Message)); } if (idStyle == ObjectId.Null) { idStyle = BaseObjs._civDoc.Styles.LabelSetStyles.AlignmentLabelSetStyles.Add(name); } try { using (Transaction tr = BaseObjs.startTransactionDb()) { alignLabelSetStyle = (AlignmentLabelSetStyle)tr.GetObject(idStyle, OpenMode.ForWrite); alignLabelSetStyle.Description = "Program Generated"; idItem = BaseObjs._civDoc.Styles.LabelStyles.AlignmentLabelStyles.MajorStationLabelStyles.Add("Parallel with line Tick"); LabelStyle labelStyle = (LabelStyle)tr.GetObject(idItem, OpenMode.ForWrite); try { labelStyle.RemoveComponent("New Tick"); } catch (System.Exception ex) { BaseObjs.writeDebug(string.Format("{0} Align_Style.cs: line: 129", ex.Message)); } try { ObjectId id = labelStyle.AddComponent("Tick", LabelStyleComponentType.Tick); LabelStyleTickComponent cmpnnt = (LabelStyleTickComponent)tr.GetObject(id, OpenMode.ForWrite); cmpnnt.Tick.Lineweight.Value = LineWeight.LineWeight060; cmpnnt.Tick.AlignWithObject.Value = true; cmpnnt.Tick.RotationAngle.Value = 0.0; cmpnnt.General.Visible.Value = true; } catch (System.Exception ex) { BaseObjs.writeDebug(string.Format("{0} Align_Style.cs: line: 141", ex.Message)); } try { labelStyle.RemoveComponent("New Block"); } catch (System.Exception ex) { BaseObjs.writeDebug(string.Format("{0} Align_Style.cs: line: 147", ex.Message)); } try { labelStyle.RemoveComponent("New Line"); } catch (System.Exception ex) { BaseObjs.writeDebug(string.Format("{0} Align_Style.cs: line: 154", ex.Message)); } try { ObjectId id = labelStyle.AddComponent("Line", LabelStyleComponentType.Line); LabelStyleLineComponent cmpnnt = (LabelStyleLineComponent)tr.GetObject(id, OpenMode.ForWrite); cmpnnt.Line.Color.Value = Autodesk.AutoCAD.Colors.Color.FromRgb(255, 127, 0); cmpnnt.Line.Angle.Value = 2.094; cmpnnt.Line.StartPointXOffset.Value = 0.005; cmpnnt.Line.StartPointYOffset.Value = -0.005; cmpnnt.General.Visible.Value = true; } catch (System.Exception ex) { BaseObjs.writeDebug(string.Format("{0} Align_Style.cs: line: 167", ex.Message)); } try { labelStyle.RemoveComponent("New Text"); } catch (System.Exception ex) { BaseObjs.writeDebug(string.Format("{0} Align_Style.cs: line: 174", ex.Message)); } try { ObjectId id = labelStyle.AddComponent("Text", LabelStyleComponentType.Text); LabelStyleTextComponent cmpnnt = (LabelStyleTextComponent)tr.GetObject(id, OpenMode.ForWrite); cmpnnt.Text.XOffset.Value = 60; cmpnnt.Text.YOffset.Value = -0.25 - cmpnnt.Text.Height.Value; cmpnnt.Text.Color.Value = Autodesk.AutoCAD.Colors.Color.FromRgb(0, 255, 0); cmpnnt.Text.Contents.Value = "STA=<[Station Value(Uft|FS|P2|RN|AP|Sn|TP|B2|EN|W0|OF)]>"; cmpnnt.General.Visible.Value = true; } catch (System.Exception ex) { BaseObjs.writeDebug(string.Format("{0} Align_Style.cs: line: 188", ex.Message)); } alignLabelSetStyle.Add(labelStyle.ObjectId); AlignmentLabelSetItem stationStyleMajor = alignLabelSetStyle[alignLabelSetStyle.Count - 1]; stationStyleMajor.Increment = 20; tr.Commit(); } } catch (System.Exception ex) { BaseObjs.writeDebug(string.Format("{0} Align_Style.cs: line: 200", ex.Message)); } return(idStyle); }