Without the latest fix: When we select 10 points >> 9 segments the resulting polyline may have 11 vertices.Shutterstock wrote: ↑Mon Jun 19, 2023 8:44 amWhere do you the a duplicated node? Can you give me what you are testing so I can reproduce?
Stepping through such a polyline with the vertex index, we discover that the last vertex is identical to the previous one.
Probably just nearly, taken that the rounded X/Y values match even with 8 decimal digits.
The fixed DiscretizeArc.discretizeArc verifies the last segment length.
The comparison is made relative so this should work for every size of arc and any number of points.
When that segment is less than 1% of the intended length it is removed but the polyline is forced to end at the arc end ...
queryAllEntities() can be slow ... Read:
https://qcad.org/doc/qcad/3.0/developer ... 3c488b7f9d
Why not query all arcs: var entitiesIds = doc.queryAllEntities(false, false, RS.EntityArc);
The filtering is then done in C++?
Remind that if you put all arcs on a dedicated layer then:
- You don't have a reference to where they came from.
- The approximation by polylines is casted on that layer too.
Then you might want to consider the maximum deviation between the arc and the segments.Shutterstock wrote: ↑Mon Jun 19, 2023 8:44 amEach arc don't hold the same importance, so simply discretizing all arcs by the same length is not optimal. And chosing a length instead of a number of points is less intuitive for the user
The given tolerance would then dictate the largest length of the sagitta, and that relates to the largest arc-segment sweep.
Chopping the arc in segments with a adapted partial sweep that sums to the total sweep.
You now have a QCAD tool that acts on the selected arc ... Implementing more/all arcs is yet another way, another script.
Regards,
CVH