Autodesk ObjectARX
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
How to convert spline into polyline
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
How to convert spline into polyline without using the function of toPolyline in AcdbSpline member?
plz provide some sample code!!!
GVaradarajan
Solved! Go to Solution.
Re: How to convert spline into polyline
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
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
Re: How to convert spline into polyline
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
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.
GVaradarajan
Re: How to convert spline into polyline
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
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
Re: How to convert spline into polyline
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
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
GVaradarajan
Re: How to convert spline into polyline
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
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

