Page 1 of 2

Exploding Splines

Posted: Mon May 08, 2017 2:10 pm
by andrew
Splines are convenient drawing elements to represent non-circular, non-elliptical curves. Unfortunately, when drawings are further processed for example through CAM (G-Code or similar), splines often need to be broken down into simpler elements. Since most CNC machines do not support splines, splines are often automatically converted into tiny line segments which has the potential to slow down the machine substantially.

To prevent this, you can convert splines in QCAD before handing the file to the CNC processor. QCAD can convert splines into polylines with tangentially connected arc segments (fewer nodes, guaranteed smoothness, i.e. no "kinks").

First, please check your preferences under:
Edit > Application Preferences > Modify > Explode
Make sure that Explode splines to polylines with line segments is unchecked as shows in this screenshot:
Screen Shot 2017-05-10 at 14.47.33.png
Screen Shot 2017-05-10 at 14.47.33.png (141.7 KiB) Viewed 47451 times
Adjust the spline approximation tolerance (maximum error). The larger this value, the fewer nodes you will get. Try a value of 0.01, 0.1 or 1.0 and check the different results.
Screen Shot 2017-05-10 at 14.49.53.png
Screen Shot 2017-05-10 at 14.49.53.png (141.29 KiB) Viewed 47450 times
To convert splines into polylines with arc segments, simply select the splines and choose Modify > Explode.
Screen Shot 2017-05-08 at 15.09.15.png
Screen Shot 2017-05-08 at 15.09.15.png (25.64 KiB) Viewed 47492 times
Original spline (top) and exploded spline with 14 nodes (bottom).

Re: Exploding Splines

Posted: Mon May 08, 2017 4:05 pm
by ross
Hi Andrew

Thank you

Ross

Re: Exploding Splines

Posted: Sat May 19, 2018 11:42 pm
by CVH
Hint
Keep a copy off your spline(-s) to revert to.
There ain't no easy way back from polys to splines exept undoing all the changes you made in between.
nor after closing.

Re: Exploding Splines

Posted: Mon Aug 20, 2018 4:51 pm
by benjamindahl
Hello, exploding splines to polylines with arcs is still unsatisfying.
Either I set the tolerance to below 0.1 and I get too many segments or I set the tolerance above 0.1 and I get a path with a too big offset.

Any solution?

As a reference I put a polyline aside, which I converted with a CAD called eMachineShop

Cheers. Benny
Bildschirmfoto 2018-08-20 um 17.47.39.png
Bildschirmfoto 2018-08-20 um 17.47.39.png (260.26 KiB) Viewed 43104 times

Re: Exploding Splines

Posted: Mon Aug 20, 2018 8:48 pm
by CVH
Mentioned this too halfway this post:
https://www.qcad.org/rsforum/viewtopic.php?t=5566

Re: Exploding Splines

Posted: Mon Aug 20, 2018 9:47 pm
by andrew
The eMachineShop algorithm compromises on tangency. I.e. you are getting 'corners' at nodes and the curve is no longer smooth. It's quite possibly the simplifying step that does that. QCAD does not have a simplification algorithm that compromises on tangency.

Re: Exploding Splines

Posted: Tue Aug 21, 2018 8:22 am
by benjamindahl
Ok, really good to know, but as a matter of facts, these corners created by emachine are not visible for us at this scaling and we can ignore them because our woodworking tools are a lot rougher than the given offset tolerance. Do you know any script which compromises on tangency? Or could this be a »checkbox-option« for future releases?

Re: Exploding Splines

Posted: Tue Aug 21, 2018 9:10 am
by andrew
benjamindahl wrote:
Tue Aug 21, 2018 8:22 am
Do you know any script which compromises on tangency?
Unfortunately not, no.
benjamindahl wrote:
Tue Aug 21, 2018 8:22 am
Or could this be a »checkbox-option« for future releases?
We don't have any plans in that direction. Perfect tangency (smoothness) is usually the deciding factor for choosing splines..

Re: Exploding Splines

Posted: Tue Aug 21, 2018 5:25 pm
by benjamindahl
Hey andrew.
On your site it's told that the CAM-addon seems to have some options regarding that problem. How could that maybe help with our problem?

https://www.qcad.org/en/qcad-documentat ... d-features
CAM Export:
Tool radius compensation:
as G41/G42
computed coordinates
Entity conversion:
Splines as tangentially connected arcs
Ellipses as arc segments
Arcs as line segments (optional)
Other complex entities as lines and arcs
Postprocessors:
G-Code (generic)
DXF (output toolpaths in correct order to DXF)
output splines as splines or arcs
output ellipses as ellipses or arcs
optionally flatten output
optionally open output after conversion
configure DXF version
Is there any way to convert the path to CAM code and then back to dxf?

Re: Exploding Splines

Posted: Tue Aug 21, 2018 5:48 pm
by andrew
Presumably, you are referring to "output splines as splines or arcs". That's exactly the same that QCAD does when exploding splines, i.e. creating exactly tangentially connected bi-arcs.

Re: Exploding Splines

Posted: Wed Aug 22, 2018 7:50 am
by benjamindahl
Yeah of course, that wouldn't help eather.
B

Re: Exploding Splines

Posted: Wed Aug 22, 2018 7:51 pm
by CVH
Andrew, all,
I don't think a simplifying step as that of eMachineShop will induces sharp corners.
Simplifying or smoothing for CNC is to get rid of corners, short segments and enhance tangency.


About earlier posts,
Guys!? The accuracy scale, please.
Better than 0.05 on a piece that is 2800 high and 1200 width.
Thats less than 0.004%. And this for artwork.
With this accuracy demand even the runout of the spindel starts to matter.

Yes I know, I am an engraver and making pockets and/or inserts with CNC can be troublesome.
Especially in the sub mm range.
These are not the problems that are solved only with the accuracy of curve fitting in CAD.
That's the design itself and sure we want the spline to be properly approximated to start with.

Once translated to G1 an G2/G3 it is the CNC side that has to be conserned. Again interpollation occurs.
Path trajectory strategy plays a role but mostly the mechanics and its real tolerance and stiffness are important.
Investigated G61 vs G64 P.. or equivalent and what 'Look ahead feed' is and how it is translated to motion.
CNC Feed mostly is not of a consern, acceleration is.
Without a plan to accelerate in the given path no Feed-speed can be obtained.

I can tune for high speed with small to very small line segments.
The trajectory planner will accelerate through corners like it was butter below a certain tangency error limit.
To do so, the small corners will be cut in an unknown manner, the real hard corners in a controlled manner.
Need real corners, use a different path trajectory strategy that will be slower.


About the spline approximation.
Nevertheless, as -benjamindahl- points out the approximation is off.
Looking in detail it becomes more and more obvious.

Read about my findings in the pdf. New drawing added. Results & calcs in BiarcFitting.xls added.

My findings in short are:
+ In this example QCAD explodes splines with the given approximation criteria met.
Q: What accuracy does QCAD uses when it auto explode? That of the AppPrefs or a fixed value?
+ QCAD returns Biarcs that connect in perfect tangency for the same spline segment.
+ On the other hand QCAD preserves the tangent angles at the spline knotpoints.
- QCAD may cast arcs for Biarc-fitting in an odd way.
Q: What is the QCAD approach and how is this coded?
Lots of quadratic equations opens lots of choises and are prone to errors.
- Biarc solutions are returned as soon as the given approximation criteria is met.
-- QCAD does not find the best solution in a Biarc-fitting solution field.

Regards,
CVH

Re: Exploding Splines

Posted: Thu Aug 23, 2018 12:04 pm
by benjamindahl
Well, thanks for all the explanation and I admit the accuracy is maybe a bit high for this particular purpose. But sometimes we also have really small pieces of about 10 cm or have artworks with scale of 1:100 and then the accuracy matters a bit more. And yes … corners do matter, because we like to have control over them. And yes, cvm,
That's the design itself and sure we want the spline to be properly approximated to start with.
And to be clear, we don't want higher accuracy than 0.05. We want less deformation on particual points on the curve at an accuracy of let's say 0.1.
We know, it's an artistic approach and we want the curve »to look« identically and have as few segments as possible to get there.

Cheers

Benny

Re: Exploding Splines

Posted: Thu Aug 23, 2018 5:00 pm
by CVH
benjamindahl wrote:
Thu Aug 23, 2018 12:04 pm
We want less deformation on particual points on the curve
For this Biarc-fitting should be done optimal.

Regards.

Re: Exploding Splines

Posted: Fri Aug 24, 2018 8:40 am
by benjamindahl
Well, should'nt be impossible, right? A quick google says somebody already tried with QCAD
https://wiki.hive13.org/view/BezierSpli ... tingScript

And for other applications there seem to be endless recources
http://www.ryanjuckett.com/programming/ ... rpolation/
https://hakantiftikci.wordpress.com/200 ... e-fitting/
https://sourceforge.net/p/dxf2gcode/wiki/ImportExport/

So how do we get there?