This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[CommandMethod("addGeneralLabelStyle")] | |
public void addGeneralLabelStyle() // This method can have any name | |
{ | |
ObjectId labelStyleId = getGeneralLabelStyle("Asphalt"); | |
if (labelStyleId == ObjectId.Null) | |
{ | |
labelStyleId = addGeneralLabelStyel("Asphalt"); | |
} | |
setGeneralProperties(labelStyleId, "SHR", "C-ROAD-LABL", true, Autodesk.Civil.OrientationReferenceType.View, true, 110, true); | |
setTextComponentContents(labelStyleId, "ASPHALT", "Asphalt"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void setTextComponentContents(ObjectId labelStyleId, string contentString, string componentName) | |
{ | |
Document acadDoc = Application.DocumentManager.MdiActiveDocument; | |
CivilDocument civilDoc = CivilApplication.ActiveDocument; | |
using (Transaction trans = acadDoc.Database.TransactionManager.StartOpenCloseTransaction()) | |
{ | |
LabelStyle lblStyle = trans.GetObject(labelStyleId, OpenMode.ForWrite) as LabelStyle; | |
LabelStyleTextComponent textComponent = trans.GetObject(lblStyle.GetComponents(LabelStyleComponentType.Text)[0], OpenMode.ForWrite) as LabelStyleTextComponent; | |
textComponent.Name = componentName; | |
textComponent.Text.Contents.Value = contentString; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void setTextComponentContents(ObjectIdCollection componentIds, string contentString, string componentName) | |
{ | |
Document acadDoc = Application.DocumentManager.MdiActiveDocument; | |
CivilDocument civilDoc = CivilApplication.ActiveDocument; | |
using (Transaction trans = acadDoc.Database.TransactionManager.StartOpenCloseTransaction()) | |
{ | |
foreach (ObjectId id in componentIds) | |
{ | |
LabelStyleTextComponent textComponent = trans.GetObject(id, OpenMode.ForWrite) as LabelStyleTextComponent; | |
textComponent.Name = componentName; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public ObjectIdCollection getLabelStyleComponentIds(ObjectId labelStyleId, LabelStyleComponentType componentType) | |
{ | |
ObjectIdCollection componentIds = new ObjectIdCollection(); | |
Document acadDoc = Application.DocumentManager.MdiActiveDocument; | |
CivilDocument civilDoc = CivilApplication.ActiveDocument; | |
using (Transaction trans = acadDoc.Database.TransactionManager.StartOpenCloseTransaction()) | |
{ | |
LabelStyle lblstyle = trans.GetObject(labelStyleId, OpenMode.ForRead) as LabelStyle; | |
componentIds = lblstyle.GetComponents(componentType); | |
trans.Commit(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void setGeneralProperties(ObjectId labelStyleId, string textStyle, string layer, bool visiblity, | |
Autodesk.Civil.OrientationReferenceType orientationReference, bool planReadability, double prBias | |
) | |
{ | |
Document acadDoc = Application.DocumentManager.MdiActiveDocument; | |
CivilDocument civilDoc = CivilApplication.ActiveDocument; | |
using (Transaction trans = acadDoc.Database.TransactionManager.StartOpenCloseTransaction()) | |
{ | |
LabelStyle lblstyle = trans.GetObject(labelStyleId, OpenMode.ForWrite) as LabelStyle; | |
lblstyle.Properties.Label.TextStyle.Value = textStyle; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public ObjectId getGeneralLabelStyle(string name) | |
{ | |
ObjectId lblId = ObjectId.Null; | |
Document acadDoc = Application.DocumentManager.MdiActiveDocument; | |
CivilDocument civilDoc = CivilApplication.ActiveDocument; | |
Boolean hasStyle = civilDoc.Styles.LabelStyles.GeneralNoteLabelStyles.Contains(name); | |
if (hasStyle) | |
{ | |
using (Transaction trans = acadDoc.Database.TransactionManager.StartOpenCloseTransaction()) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public ObjectId addGeneralLabelStyel(string name) | |
{ | |
ObjectId lblId = ObjectId.Null; | |
Document acadDoc = Application.DocumentManager.MdiActiveDocument; | |
CivilDocument civilDoc = CivilApplication.ActiveDocument; | |
using (Transaction trans = acadDoc.Database.TransactionManager.StartOpenCloseTransaction()) | |
{ | |
lblId = civilDoc.Styles.LabelStyles.GeneralNoteLabelStyles.Add(name); | |
trans.Commit(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[CommandMethod("selectBlocksOnly")] | |
public void selectBlocksOnly() | |
{ | |
Document acadDoc = Application.DocumentManager.MdiActiveDocument; | |
Editor editor = acadDoc.Editor; | |
PromptSelectionOptions promptSelOpt = new PromptSelectionOptions(); | |
promptSelOpt.MessageForAdding = "Select block objects: "; | |
TypedValue[] tVs = new TypedValue[] { new TypedValue((int)DxfCode.Start, RXClass.GetClass(typeof(BlockReference)).DxfName) }; | |
SelectionFilter filter = new SelectionFilter(tVs); | |
PromptSelectionResult result = editor.GetSelection(promptSelOpt, filter); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[CommandMethod("basicSelSet")] | |
public void basicSelSet() | |
{ | |
Document acadDoc = Application.DocumentManager.MdiActiveDocument; | |
Editor editor = acadDoc.Editor; | |
PromptSelectionOptions promptSelOpt = new PromptSelectionOptions(); | |
promptSelOpt.MessageForAdding = "Select any objects: "; | |
PromptSelectionResult result = editor.GetSelection(promptSelOpt); | |
if (result.Status == PromptStatus.OK) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public Autodesk.AutoCAD.DatabaseServices.ObjectId getGeneralNoteStyle(string gnName) | |
{ | |
Autodesk.AutoCAD.ApplicationServices.Document acadDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument; | |
Autodesk.Civil.ApplicationServices.CivilDocument civilDoc = Autodesk.Civil.ApplicationServices.CivilApplication.ActiveDocument; | |
Autodesk.AutoCAD.DatabaseServices.ObjectId generalNoteStyleId = Autodesk.AutoCAD.DatabaseServices.ObjectId.Null; | |
using (Autodesk.AutoCAD.DatabaseServices.Transaction trans = acadDoc.Database.TransactionManager.StartOpenCloseTransaction()) | |
{ | |
foreach (Autodesk.AutoCAD.DatabaseServices.ObjectId gnsId in civilDoc.Styles.LabelStyles.GeneralNoteLabelStyles) | |
{ | |
Autodesk.Civil.DatabaseServices.NoteLabel gns = gnsId.GetObject(Autodesk.AutoCAD.DatabaseServices.OpenMode.ForRead) as Autodesk.Civil.DatabaseServices.NoteLabel; |
NewerOlder