There is a method called Polyline.ConvertTo that can convert a lightweight polyline into a polyline 2d object, but this method requires a special treatment.
First, it is required to use StartOpenCloseTransaction method to create a new transaction, instead regular StartTransaction. Second, remove the old polyline and append the newly created polyline 2d.
ObjectId plineId = // obtain here…
Database db =
Application.DocumentManager.MdiActiveDocument.Database;
using (Transaction t =
db.TransactionManager.StartOpenCloseTransaction())
{
using (Polyline pline = (Polyline)
t.GetObject(plineId, OpenMode.ForWrite))
{
t.AddNewlyCreatedDBObject(pline, false);
Polyline2d poly2 = pline.ConvertTo(true);
t.AddNewlyCreatedDBObject(poly2, true);
t.Commit();
}
}

Leave a Reply