Try this function...
public void
ConvertPlines()
{
Editor ed =
Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
PromptSelectionOptions prOpts = new PromptSelectionOptions();
prOpts.MessageForAdding = "\nSelect AcDb2dPolylines";
TypedValue[] filter = new TypedValue[1];
Object obj1 = "POLYLINE";
filter[0] = new TypedValue(0, obj1);
SelectionFilter selFilter = new SelectionFilter(filter);
PromptSelectionResult res = ed.GetSelection(prOpts, selFilter);
if (res.Status != PromptStatus.OK)
return;
int successCount = 0;
int failedCount = 0;
Autodesk.AutoCAD.DatabaseServices.TransactionManager tm =
Utils.Db.GetCurDwg().TransactionManager;
using (Autodesk.AutoCAD.DatabaseServices.Transaction tr =
tm.StartTransaction()) {
ObjectId[] objIds = res.Value.GetObjectIds();
foreach (ObjectId objId in objIds) {
using (Entity oldPline = (Entity)objId.Open(OpenMode.ForWrite)) {
using (Polyline newPline = new Polyline()) {
try {
newPline.ConvertFrom(oldPline, true);
successCount++;
}
catch (Autodesk.AutoCAD.Runtime.Exception e) {
ed.WriteMessage("\nERROR: {0}", e.ErrorStatus.ToString());
failedCount++;
}
newPline.Close();
}
}
}
tr.Commit();
}
ed.WriteMessage("\nConverted {0:d} polylines.", successCount);
ed.WriteMessage("\nFailed to convert {0:d} polylines.", failedCount);
}
}
Sorry for the formatting... I can't seem to ever get that to work with
Outlook Express. Note. There are legitimate reasons it will fail to
convert, and thus the extra error checking. Some AcDb2dPolylines are things
like Fit curves and they don't convert. See the documentation of
ConvertFrom() for details.
Jim Awe
Autodesk, Inc.
wrote in message news:4880437@discussion.autodesk.com...
Is there a easy way to convert a AcadPolyline To a AcadLWPolyline.
Something like :
AcadLWpolyline = AcadPolyline.convertToLW
Harold van Aarsen