.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Convert AcadPolyline To AcadLWPolyline

2 REPLIES 2
Reply
Message 1 of 3
as
1477 Views, 2 Replies

Convert AcadPolyline To AcadLWPolyline

Is there a easy way to convert a AcadPolyline To a AcadLWPolyline.

Something like :
AcadLWpolyline = AcadPolyline.convertToLW

Harold van Aarsen
2 REPLIES 2
Message 2 of 3
Anonymous
in reply to: as

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
Message 3 of 3
connectajayanand
in reply to: as

This Video is about creating a macro for extracting coordinates of an AutoCAD Polyline.

 

Topics Discussed are
1. Extracting Coordinates of Polyline
2. Extracting length of Polyline
3. Extracting the number of vertices of a Polyline

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost