Create arcs and circles from tessellated segments
Posted: Fri Oct 09, 2020 3:06 pm
I would love to have a feature/tool/script/plug-in added to QCAD. I work regularly with DXF files generated from SketchUp, and the problem is that SketchUp generates tessellated arc and circles in all 2D output. This tessellated output doesn't work well with CNC machines because the tool path generation can create stops and starts as it randomly sees fit, or the automatic conversion to smooth curves just flat out sucks and a perfect 24 segment circle gets converted to three or four bezier curves that are no longer accurate.
So it's common practice for me to use three-point arcs and two point circles to replace the tessellated geometry, which goes fairly quickly but the deletion of the existing line segments is the tedious and error prone part... Because there is now overlapping geometry, I find it best to drag a selection box across part of the arc/circle (without selecting the arc/circle) and delete those segments then drag a selection box across the remaining segments to delete them.
So, I have been mulling writing a plug-in to take a user selection of line segments, order the endpoints, pick the start and end points and one near the middle (depends on odd or even number of segments if you have a midpoint), then generate a three-point arc, delete the original selection and select the newly generated arc so the user has visual confirmation. If the points all share two entities, you have a complete circle and can generate a two point circle, again deleting the original selection and selecting the newly generated circle. Of course there are inaccuracies and edge-cases to automating anything, but 99% of the scenarios can be covered with really simlpe logic and minimal error checking. The tessellated geometry is always quite clean.
I'm an old-school developer, but this has been on my to-do list for waaayyyyyy too long because it's always hardest to jump into a framework and gain familiarity before you can actually be constructive, and I just haven't done that yet :/ I pulled the source and have browsed through many of the scripts for the native tools (like the ShapeAlgorithms class), but I haven't found a good example script to jump-off from that does something with a user selection of existing entities (can anyone suggest an appropriate existing script?) It looks like I would use queryContainedEntities() and then work with the returned set of entities, then create an RArcEntity or RCircleEntity and insert it into the document tree, deleting the original contained entities. Then write the other 99% of the code that makes it usable
If anyone with experience wants to go at this together, I'm all ears. I'd generate icons and psuedo-code the behavior logic I'd like to see, as well as handling edge cases and error conditions, and whatever else I can write.
Thanks,
Brock
So it's common practice for me to use three-point arcs and two point circles to replace the tessellated geometry, which goes fairly quickly but the deletion of the existing line segments is the tedious and error prone part... Because there is now overlapping geometry, I find it best to drag a selection box across part of the arc/circle (without selecting the arc/circle) and delete those segments then drag a selection box across the remaining segments to delete them.
So, I have been mulling writing a plug-in to take a user selection of line segments, order the endpoints, pick the start and end points and one near the middle (depends on odd or even number of segments if you have a midpoint), then generate a three-point arc, delete the original selection and select the newly generated arc so the user has visual confirmation. If the points all share two entities, you have a complete circle and can generate a two point circle, again deleting the original selection and selecting the newly generated circle. Of course there are inaccuracies and edge-cases to automating anything, but 99% of the scenarios can be covered with really simlpe logic and minimal error checking. The tessellated geometry is always quite clean.
I'm an old-school developer, but this has been on my to-do list for waaayyyyyy too long because it's always hardest to jump into a framework and gain familiarity before you can actually be constructive, and I just haven't done that yet :/ I pulled the source and have browsed through many of the scripts for the native tools (like the ShapeAlgorithms class), but I haven't found a good example script to jump-off from that does something with a user selection of existing entities (can anyone suggest an appropriate existing script?) It looks like I would use queryContainedEntities() and then work with the returned set of entities, then create an RArcEntity or RCircleEntity and insert it into the document tree, deleting the original contained entities. Then write the other 99% of the code that makes it usable
If anyone with experience wants to go at this together, I'm all ears. I'd generate icons and psuedo-code the behavior logic I'd like to see, as well as handling edge cases and error conditions, and whatever else I can write.
Thanks,
Brock