Exploding Splines

Tips and tricks you want to share with other users. Tutorials, user submitted documentation, etc.

Moderator: andrew

User avatar
andrew
Site Admin
Posts: 9019
Joined: Fri Mar 30, 2007 6:07 am

Exploding Splines

Post by andrew » Mon May 08, 2017 2:10 pm

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 46607 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 46606 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 46648 times
Original spline (top) and exploded spline with 14 nodes (bottom).

ross
Active Member
Posts: 45
Joined: Wed Sep 30, 2015 2:11 pm

Re: Exploding Splines

Post by ross » Mon May 08, 2017 4:05 pm

Hi Andrew

Thank you

Ross

CVH
Premier Member
Posts: 3364
Joined: Wed Sep 27, 2017 4:17 pm

Re: Exploding Splines

Post by CVH » Sat May 19, 2018 11:42 pm

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.

benjamindahl
Junior Member
Posts: 11
Joined: Mon Aug 20, 2018 4:23 pm
Location: Berlin, Germany

Re: Exploding Splines

Post by benjamindahl » Mon Aug 20, 2018 4:51 pm

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 42260 times
Attachments
180803_Scherenschnitt_2-2-forum.dxf
(361.97 KiB) Downloaded 1314 times

CVH
Premier Member
Posts: 3364
Joined: Wed Sep 27, 2017 4:17 pm

Re: Exploding Splines

Post by CVH » Mon Aug 20, 2018 8:48 pm

Mentioned this too halfway this post:
https://www.qcad.org/rsforum/viewtopic.php?t=5566

User avatar
andrew
Site Admin
Posts: 9019
Joined: Fri Mar 30, 2007 6:07 am

Re: Exploding Splines

Post by andrew » Mon Aug 20, 2018 9:47 pm

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.

benjamindahl
Junior Member
Posts: 11
Joined: Mon Aug 20, 2018 4:23 pm
Location: Berlin, Germany

Re: Exploding Splines

Post by benjamindahl » Tue Aug 21, 2018 8:22 am

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?

User avatar
andrew
Site Admin
Posts: 9019
Joined: Fri Mar 30, 2007 6:07 am

Re: Exploding Splines

Post by andrew » Tue Aug 21, 2018 9:10 am

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..

benjamindahl
Junior Member
Posts: 11
Joined: Mon Aug 20, 2018 4:23 pm
Location: Berlin, Germany

Re: Exploding Splines

Post by benjamindahl » Tue Aug 21, 2018 5:25 pm

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?

User avatar
andrew
Site Admin
Posts: 9019
Joined: Fri Mar 30, 2007 6:07 am

Re: Exploding Splines

Post by andrew » Tue Aug 21, 2018 5:48 pm

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.

benjamindahl
Junior Member
Posts: 11
Joined: Mon Aug 20, 2018 4:23 pm
Location: Berlin, Germany

Re: Exploding Splines

Post by benjamindahl » Wed Aug 22, 2018 7:50 am

Yeah of course, that wouldn't help eather.
B

CVH
Premier Member
Posts: 3364
Joined: Wed Sep 27, 2017 4:17 pm

Re: Exploding Splines

Post by CVH » Wed Aug 22, 2018 7:51 pm

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
Attachments
180803_Scherenschnitt_Adapted.dxf
(394.77 KiB) Downloaded 1267 times
BiarcFitting.xlsx
(12.71 KiB) Downloaded 1235 times
CurveFitting_expl_spline.pdf
(191.67 KiB) Downloaded 1304 times

benjamindahl
Junior Member
Posts: 11
Joined: Mon Aug 20, 2018 4:23 pm
Location: Berlin, Germany

Re: Exploding Splines

Post by benjamindahl » Thu Aug 23, 2018 12:04 pm

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

CVH
Premier Member
Posts: 3364
Joined: Wed Sep 27, 2017 4:17 pm

Re: Exploding Splines

Post by CVH » Thu Aug 23, 2018 5:00 pm

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.
Last edited by CVH on Tue Jun 23, 2020 7:14 pm, edited 1 time in total.

benjamindahl
Junior Member
Posts: 11
Joined: Mon Aug 20, 2018 4:23 pm
Location: Berlin, Germany

Re: Exploding Splines

Post by benjamindahl » Fri Aug 24, 2018 8:40 am

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?

Post Reply

Return to “QCAD Tips and Tutorials”