Message 1 of 19
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
This is an example of how to add labels at the picked points along a ParcelSegment without needing to reference the COM libraries (no .NET methods exist to do this, as of C3D 2021).
[CommandMethod("TestCreateParcelLabels")]
public void createparcellabels()
{
var doc = Application.DocumentManager.MdiActiveDocument;
var db = doc.Database;
var ed = doc.Editor;
var entOpts = new PromptEntityOptions("\nSelect a parcelsegment at location for label: ");
entOpts.SetRejectMessage("..not a ParcelSegment, try again.");
entOpts.AddAllowedClass(typeof(ParcelSegment), true);
var entsel = ed.GetEntity(entOpts);
using (Transaction tr = db.TransactionManager.StartTransaction())
{
var linId = CivilApplication.ActiveDocument.Settings.GetSettings<SettingsCmdAddParcelSegmentLabels>().Styles.ParcelLineLabelStyleId.Value;
var crvId = CivilApplication.ActiveDocument.Settings.GetSettings<SettingsCmdAddParcelSegmentLabels>().Styles.ParcelCurveLabelStyleId.Value;
var linStyle = tr.GetObject(linId, OpenMode.ForRead).AcadObject;
var crvStyle = tr.GetObject(crvId, OpenMode.ForRead).AcadObject;
while (entsel.Status == PromptStatus.OK)
{
dynamic p = tr.GetObject(entsel.ObjectId, OpenMode.ForRead).AcadObject;
p.SegmentLabels.Add(linStyle, crvStyle, entsel.PickedPoint.ToArray());
entsel = ed.GetEntity(entOpts);
}
tr.Commit();
}
}
Solved! Go to Solution.