C3D2013 How to display Labels on a Polyline?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello everyone, I am new to Autocad Civil 3D 2013 .NET API and I created a polyline and my problem is I have no idea of showing labels on it.
This is I really want to do:
> I want to display the index of the points.
> and I want to display the area of the polyline beside it.
By the way, I used C# as a language. Here is my code for making a polyline just for you to know and if you have any ideas how to
incorporate labels and areas with that code.
[CommandMethod("AddLightweightPolyline")]
public static void AddLightweightPolyline()
{
// Get the current document and database
Document acDoc = Application.DocumentManager.MdiActiveDocument;
Database acCurDb = acDoc.Database;
// Start a transaction
using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
{
// Open the Block table for read
BlockTable acBlkTbl;
acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId,
OpenMode.ForRead) as BlockTable;
// Open the Block table record Model space for write
BlockTableRecord acBlkTblRec;
acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace],
OpenMode.ForWrite) as BlockTableRecord;
// Create a polyline with two segments (3 points)
using (Polyline acPoly = new Polyline())
{
acPoly.AddVertexAt(0, new Point2d(-315.27, 105.15), 0, 0, 0);
acPoly.AddVertexAt(1, new Point2d(-326.2, 101.66), 0, 0, 0);
acPoly.AddVertexAt(2, new Point2d(-326.75, 102.49), 0, 0, 0);
acPoly.AddVertexAt(3, new Point2d(-331.02, 109.33), 0, 0, 0);
acPoly.AddVertexAt(4, new Point2d(-318.39, 113.59), 0, 0, 0);
acPoly.AddVertexAt(5, new Point2d(-315.27, 105.15), 0, 0, 0);
//acPoly.AddVertexAt(5, new Point2d(-315.27, 105.15), 0, 0, 0);
acPoly.Closed = true;
// Add the new object to the block table record and the transaction
acBlkTblRec.AppendEntity(acPoly);
acTrans.AddNewlyCreatedDBObject(acPoly, true);
}
// Save the new object to the database
acTrans.Commit();
}
}
I also attached a file of what I am trying to display.
Please help me with this problem. I appreciate the effort. Thanks!
@BushW has edited your subject line for clarity: How to display Labels on a Polyline?