How to convert spline into polyline

How to convert spline into polyline

Anonymous
Not applicable
3,179 Views
5 Replies
Message 1 of 6

How to convert spline into polyline

Anonymous
Not applicable

How to convert spline into polyline without using the function of toPolyline in AcdbSpline member?

 

plz provide some sample code!!!

0 Likes
Accepted solutions (1)
3,180 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable
Accepted solution

there is no simple way to do this. So, the way I'm doing this is:

1. choose a minimal distance A, for example 0.1 or 0.5

2. collect all of the spline's points at  A, A*2, A*3, ... 

3. use group of three points to find out if all of them are on the same LINE. If it's true, kill middle point

4. repeate 3 until the last collected point.

5. create polyline (2D or 3D) from the remaining points. 

6. kill the spline. 

 

Sorry, can't give you a source. But I think algorythm is enough for understanding.

 

0 Likes
Message 3 of 6

Anonymous
Not applicable

 use group of three points to find out if all of them are on the same LINE. If it's true, kill middle point---> how spline point in same line can u explain briefly.

0 Likes
Message 4 of 6

Anonymous
Not applicable

first of all collect spline points through some step, for example 1/5000 of spline's length

put then into ptArray. 

then:  

for(int i = 0; i<ptArray.length()-3; i++)

{

// first line - ptArray.at(i), ptArray.at(i+1)

// second line - ptArray.at(i+1), ptArray.at(i+2)

// if (lines have the same direction or less then permissible angle, for example 1degree in radians)

// { 

// ptArray.removeAt(i+1);
 // i--; 

// } 

0 Likes
Message 5 of 6

Anonymous
Not applicable

 

Thank for ur help

i found another way to convert spline to polyline but the output is wrongly come because of tolerance in spline.

 

AcDb3dPolyline(AcDb::Poly3dType, AcGePoint3dArray& vertices, Adesk::Boolean closed = Adesk::kFalse);

 

AcDb3dPolyline *pPline = AcDb3dPolyline(k3dQuadSplinePoly,SplinePoints);

pSpline->erase();

AppendEntity(pPline);

 

whether this method is correct to convert polyline 

 

0 Likes
Message 6 of 6

Anonymous
Not applicable

everything depends on accuracy of created polyline. if you want to have polyline's looks, like spline is shown on the screen, use my way or something similar. arx methods can't help you in this. 

 

May be in 3-5 years somethin will change in autodesk structure, an they will try to fix great quantity of "expected behavior" of their functions. but now, look at the attached picture (autocad's native command for spline to polyline convertation). black - polyline3d, red - spline, blue marks - "expected behavior" (i call it BUGS).

 acadspline2poly_convert.GIF

0 Likes