.NET
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Convert AcadPolyli ne To AcadLWPoly line
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
203 Views, 1 Replies
06-21-2005 07:26 AM
Is there a easy way to convert a AcadPolyline To a AcadLWPolyline.
Something like :
AcadLWpolyline = AcadPolyline.convertToLW
Harold van Aarsen
Something like :
AcadLWpolyline = AcadPolyline.convertToLW
Harold van Aarsen
*Jim Awe
Re: Convert AcadPolyli ne To AcadLWPoly line
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
06-21-2005 08:23 AM in reply to:
as
Try this function...
public void
ConvertPlines()
{
Editor ed =
Autodesk.AutoCAD.ApplicationServices.Application.D ocumentManager.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.TransactionManag er 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
public void
ConvertPlines()
{
Editor ed =
Autodesk.AutoCAD.ApplicationServices.Application.D
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.TransactionManag
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.
Is there a easy way to convert a AcadPolyline To a AcadLWPolyline.
Something like :
AcadLWpolyline = AcadPolyline.convertToLW
Harold van Aarsen
