Autodesk ObjectARX

## Autodesk ObjectARX

Active Contributor
Posts: 47
Registered: ‎03-16-2012
Message 1 of 6 (1,136 Views)

# How to convert spline into polyline

1136 Views, 5 Replies
06-07-2012 10:28 PM

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

plz provide some sample code!!!

With Regards,
Valued Contributor
Posts: 86
Registered: ‎03-10-2010
Message 2 of 6 (1,128 Views)

# Re: How to convert spline into polyline

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.

---
#define QUESTION(b) (2*b)||(!(2*b)) © William Shakespeare
Active Contributor
Posts: 47
Registered: ‎03-16-2012
Message 3 of 6 (1,104 Views)

# Re: How to convert spline into polyline

06-11-2012 10:02 PM in reply to: Nick1983

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.

With Regards,
Valued Contributor
Posts: 86
Registered: ‎03-10-2010
Message 4 of 6 (1,096 Views)

# Re: How to convert spline into polyline

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--;

// }

---
#define QUESTION(b) (2*b)||(!(2*b)) © William Shakespeare
Active Contributor
Posts: 47
Registered: ‎03-16-2012
Message 5 of 6 (1,080 Views)

# Re: How to convert spline into polyline

06-14-2012 12:20 AM in reply to: Nick1983

Thank for ur help

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

pSpline->erase();

AppendEntity(pPline);

whether this method is correct to convert polyline

With Regards,
Valued Contributor
Posts: 86
Registered: ‎03-10-2010
Message 6 of 6 (1,074 Views)

# Re: How to convert spline into polyline

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).

---
#define QUESTION(b) (2*b)||(!(2*b)) © William Shakespeare

Recently Solved