Here is an example for putting some points on your polylines. I also include the database method (AddPointd) for adding the points to the db so you can visualize them.
[CommandMethod("POPOLYLINE", CommandFlags.UsePickSet | CommandFlags.Redraw | CommandFlags.Modal)]
public void pointsonpolyline()
{
Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
Editor ed = doc.Editor;
Database db = doc.Database;
PromptIntegerResult pir = ed.GetInteger("Enter number of divisions: ");
if (pir.Status != PromptStatus.OK && pir.Value > 0)
{
return;
}
double how_many_times = pir.Value;
PromptEntityResult per = ed.GetEntity("Pick Polyline: ");
if (per.Status == PromptStatus.OK)
{
using (Transaction tr = db.TransactionManager.StartTransaction())
{
Entity ent = (Entity)tr.GetObject(per.ObjectId, OpenMode.ForRead);
Polyline pline = ent as Polyline;
if (pline != null)
{
if (pline.Closed == true)
{
double len = pline.Length;
DBPoint xPointdStart = new DBPoint(pline.GetPoint3dAt(0));
AddPointd(xPointdStart, 15, "Start", "Total:" + len.ToString());
double len_increment = len / how_many_times;
for (int x = 1; x <= how_many_times - 1; x++)
{
Point3d p3d = pline.GetPointAtDist(len_increment * x);
DBPoint xPointd = new DBPoint(p3d);
AddPointd(xPointd, 15, x.ToString(), (len_increment * x).ToString());
}
}
}
tr.Commit();
}
}
}
public static ObjectId AddPointd(DBPoint pdb, short color, string name, string description)
{
ObjectId result = ObjectId.Null;
Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
DocumentLock docLock = doc.LockDocument();
try
{
using (Transaction tm = doc.TransactionManager.StartTransaction())
{
BlockTable bt = (BlockTable)tm.GetObject(db.BlockTableId, OpenMode.ForWrite, false);
BlockTableRecord btr = (BlockTableRecord)tm.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite, false);
pdb.Color = Autodesk.AutoCAD.Colors.Color.FromColorIndex(Autodesk.AutoCAD.Colors.ColorMethod.ByColor, color);
ObjectId o = btr.AppendEntity(pdb);
tm.AddNewlyCreatedDBObject(pdb, true);
Entity e = (Entity)tm.GetObject(o, OpenMode.ForWrite);
HyperLinkCollection hyperls = e.Hyperlinks;
HyperLink hyper = new HyperLink();
hyper.Name = name;
hyper.Description = description;
hyperls.Add(hyper);
result = pdb.ObjectId;
tm.Commit();
}
}
catch (Autodesk.AutoCAD.Runtime.Exception) { }
catch (System.Exception) { }
finally
{
docLock.Dispose();
}
return result;
}