Autodesk ObjectARX

## Autodesk ObjectARX

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

# How to convert spline into polyline

1123 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,
Please use plain text.
Valued Contributor
Posts: 86
Registered: ‎03-10-2010
Message 2 of 6 (1,115 Views)

# Re: How to convert spline into polyline

06-08-2012 12:51 AM in reply to: varadan01

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
Please use plain text.
Active Contributor
Posts: 47
Registered: ‎03-16-2012
Message 3 of 6 (1,091 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,
Please use plain text.
Valued Contributor
Posts: 86
Registered: ‎03-10-2010
Message 4 of 6 (1,083 Views)

# Re: How to convert spline into polyline

06-12-2012 12:56 AM in reply to: varadan01

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
Please use plain text.
Active Contributor
Posts: 47
Registered: ‎03-16-2012
Message 5 of 6 (1,067 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.

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

AcDb3dPolyline *pPline = AcDb3dPolyline(k3dQuadSplinePoly,SplinePoints);

pSpline->erase();

AppendEntity(pPline);

whether this method is correct to convert polyline

With Regards,
Please use plain text.
Valued Contributor
Posts: 86
Registered: ‎03-10-2010
Message 6 of 6 (1,061 Views)

# Re: How to convert spline into polyline

06-14-2012 01:40 AM in reply to: varadan01

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
Please use plain text.

### You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

### Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Recently Solved