Can we get the segment type from Polyline2d and Polyline3d using C# ?

Can we get the segment type from Polyline2d and Polyline3d using C# ?

Anonymous
Not applicable
1,045 Views
2 Replies
Message 1 of 3

Can we get the segment type from Polyline2d and Polyline3d using C# ?

Anonymous
Not applicable

In Polyline, we have the GetSegmentType:

 

public static void GetPolylineSegment(Polyline pline){
Point3d p3d;
SegmentType stype;    int vn = pline.NumberOfVertices;    for (int i = 0; i < vn; i++){       p3d = pline.GetPoint3dAt(i);
segmentType = pline.GetSegmentType((int)pline.GetParameterAtPoint(p3d));
if (segmentType == SegmentType.Arc) {
// find an arc segment
}
else if (segmentType == SegmentType.Line) {
// find a line segment
}
// ...    } }

 

Polyline2d and Polyline3d doesn't have the same method, so is there a workaround to deal with ?

0 Likes
1,046 Views
2 Replies
Replies (2)
Message 2 of 3

pendean
Community Legend
Community Legend
You need to post in the proper customization forum: http://forums.autodesk.com/t5/autocad-customization/ct-p/AutoCADTopic1
0 Likes
Message 3 of 3

Kent1Cooper
Consultant
Consultant

The Customization Forum would be better, but in the meantime....

 

If I understand what you're asking, one thing you can do [I know how to do it in AutoLISP, but I couldn't say whether it can be done in that programming language], that works on either lightweight or heavy Polylines, is to apply Object Snap CENTER at the pick point.  If it returns anything, you've picked on an arc segment, otherwise on a line segment.  Temporarily set the APERTURE System Variable to be the same size as the PICKBOX, to avoid the possibility of catching some other nearby thing that happens to have a Center.

 

But I would point out that there's no need to make a determination for segment type on 3DPolylines, which can't have arc segments [unless, of course, you don't know what kind of object you're picking on when you pick it, in which case the above approach will appropriately determine for a 3DPolyline that you picked on a line segment].

Kent Cooper, AIA
0 Likes