AutoCAD Map 3D Developer
Welcome to Autodesk’s AutoCAD Map 3D Developer Forums. Share your knowledge, ask questions, and explore popular AutoCAD Map 3D Developer topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Read coordinates of Polyline having an Arc

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
Anonymous
950 Views, 3 Replies

Read coordinates of Polyline having an Arc

Hi,

I am reading Polyline coordinates using .NET as per below.

Polyline lwp = obj as Polyline;

for loop lwp.NumberOfVertices to read point coordinates

Point3d pt = lwp.GetPoint3dAt(i);

 

This logic helps in reading coordinates for polyline, line and point. But if it is an Arc I am getting only start point and end point coordinate which in spatial its converting as line instead of Arc.

 

Please suggest if there is a way to read the coordinates of Arc from Polyline. 

 

Regards,

Sri

3 REPLIES 3
Message 2 of 4
norman.yuan
in reply to: Anonymous

I do not quite understand your description about polyline (i.e lightweight polyline, if you are AutoCAD user, which is pure 2D entity).

 

This code:

 

Polyline lwp = obj As Polyline

for int i =0; i < lwp.NumberOfVertices; i++

    Point3d pt = lwp.GetPoint3dAt(i);

 

ONLY works if "obj" IS A POLYLINE. If the "obj" is "Line" or else, it would not work, So, what do you mean here by saying

"This logic helps in reading coordinates for polyline, line and point...."? You certain CANNOT use GetPoint3dAt() with a Line object, or Arc object, or anything other than Polyline.

 

If your question is only regarding to Polyline, then what do you mean in your post's title by "coordinates of polyline"? If the polyline has curved segment (bulge), it must have vertices at the end of the curved segment. Do you mean you actually want to know not only coordinates of all vertices, but also, the coordinates of any point on the polyline, be it on a straight segment, or curved segment. If so, yes, AutoCAD .NET API has a sraightforward methods for it, which not only applies to Polyline, but also all entities that derived from class Curve (Line, Circle, Arc):

 

Curve.GetPointAtDist(double)

Curve.GetPointAtParameter(double)

 

 

 

 

Norman Yuan

Drive CAD With Code

EESignature

Message 3 of 4
Anonymous
in reply to: norman.yuan

Hi,

Thanks much for your reply. My question is regarding reading of all coordinates in Polyline . We have a Door having a curve shape and the below code fetches only the start point and end point of the curve.

Polyline lwp = obj As Polyline

for int i =0; i < lwp.NumberOfVertices; i++

    Point3d pt = lwp.GetPoint3dAt(i);

So I am unable to read all the coordinates in the curved Segment. When I tried to print the Segment Type of the Polyline as below its printing 2 Lines & 1 Arc (the door shape has 2 lines & a curve):

SegmentType type = lwp.GetSegmentType(cnt);

 

Can you please provide more details on how to read all the coordinates of the curve in the polyline.

What will be the input for the below methods ?

Curve.GetPointAtDist(double)

Curve.GetPointAtParameter(double)

Thanks in advance.

Message 4 of 4
norman.yuan
in reply to: Anonymous

Sorry, I have difficult to understand what you really want by "... read all the coordinates of the curve ...". What does "all" mean? A curve (line, polyline...) in AutoCAD, besides its StartPoint and EndPoint (or vertices), can have countless points (coordinates) in between (i.e between Start and End Points, or between 2 vertices).

 

So, if it is a straight line, knowing start/end point, you can calculate any point along the line. If it is Arc, knowing its start and end point and its radius, you can calculate any point along the arc, but you MUST decide where the point you want it to be (not just "all points". obviously). Say, you want the points at each 5 units apart (m, mm, or whatever) from the start point along the curve path, or in the case of arc, you want the points every 5 degree of angle (which you can calculate the arc length based on the radius, then you get the path length along the arc). Then this is where Curve.GetPaointAtDist(double [distanceFormStart]) comes into play.

 

There are also other methods in the Curve class that may help you:

GetDistAtPoint()/GetParameterAtDistance()/GetParameterArPoint()

Norman Yuan

Drive CAD With Code

EESignature

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

Post to forums  

Technology Administrators


AutoCAD Beta