Page 1 of 1

Polyline to spline

Posted: Sat May 25, 2019 5:01 pm
by bergdesign
Is there a tool or script for converting a polyline to a fit-points-spline or a control-points-spline? have searched the docs, the ebook and the forums, and I haven't been able to find anything so maybe this should just be a suggested feature.

I do a lot of CNC routing, but I start with geometry from SketchUp which is of course polygonal. Most of the routing is straight lines so the polygonal nature of the 2D exported geometry is fine, but circles and curved edges pose a problem because most CAM software sucks at turning tesselated geometry into smooth machine movements. Circles are simple to reconstruct because a two-point circle is easily constructed from a polygon, but curved edges require a lot of clicking with the fit points spline tool to reconstruct. Because you already have the ability to construct a polyline from selected segments, it seems it would be easy to add two commands to then convert an existing polyline into either a fit-points-spline or a control-points-spline. I understand that this has cases where the behavior can be complicated since polylines may not be composed entirely of straight segments, but it seems that the internal functionality to convert a polyline's points into a set of usable spline points already exists, and it would save a lot of time compared to constructing a spline by clicking each point manually.

Thanks,
Brock Brandenberg

Re: Polyline to spline

Posted: Mon May 27, 2019 10:55 am
by andrew
There's no dedicated tool for that.

Here's a way to do it without clicking each point.

First, we have to set an undocumented preference in the QCAD3.ini file (we only have to do this once):
1. Misc > Development > Script Shell
2. In dialog click "Show ECMAScript Shell"
3. In the script shell, type:
RSettings.setValue("InfoStorePositions/PolylineNodes", true);
4. Press Enter

To draw a spline with fit points from polyline nodes:
1. Select the polyline
2. Misc > Information > Store Positions
3. Draw > Spline > Spline (Fit Points)
4. Misc > Information > Use Positions
5. Escape

More information about reusing drawing positions:
https://qcad.org/tutorial-reusing-drawing-positions

Re: Polyline to spline

Posted: Tue May 28, 2019 12:24 am
by bergdesign
Awesome workaround :) Thanks Andrew.

Brock

Re: Polyline to spline

Posted: Tue Aug 30, 2022 7:18 am
by ubi_laptop
hi andrew,
Im trying to do the same process you described in five steps on a mac with pro versione 3.27.1.
As i give the command "use position" the program draws the FIRST point and then wait for the following, not using other point.
I can't guess what I'm missing.
thank you for your reply and this awesome program !
daniele
Schermata 2022-08-30 alle 08.16.07.jpg
Schermata 2022-08-30 alle 08.16.07.jpg (205.02 KiB) Viewed 15412 times

Re: Polyline to spline

Posted: Tue Aug 30, 2022 7:29 am
by andrew
This preference is now available under:

Edit > Application Preferences > Info > Store Positions > Polylines

Check the option Store Nodes.

Then proceed as before to draw a spline with fit points from polyline nodes:
1. Select the polyline
2. Misc > Information > Store Positions
3. Draw > Spline > Spline (Fit Points)
4. Misc > Information > Use Positions
5. Escape

Re: Polyline to spline

Posted: Tue Aug 30, 2022 12:19 pm
by ubi_laptop
thank you. I did miss that !

Re: Polyline to spline

Posted: Tue Aug 30, 2022 7:26 pm
by CVH
Brock,
bergdesign wrote:
Sat May 25, 2019 5:01 pm
Most of the routing is straight lines so the polygonal nature of the 2D exported geometry is fine, but circles and curved edges pose a problem because most CAM software sucks at turning tesselated geometry into smooth machine movements.
It can't be smooth when it has hard corners, right.
Sorry to say but there is almost no way back from approximations by line-segments unless you really know the used algorithm and its parameters.
One can do a lot with a combination of a LAF and G64 ... But the rounding will always be arbitrary.

And, there is no certainty that nodes of a polyline with line segments are a match with the original fitpoints of a spline.
E.g. a spline with 4 fitpoints may be segmented in over 50 lines.
In the best case it will only look almost like the original spline but then with 51 fitpoints. :wink:
Still, in the absence of original data, I need to use this workaround more than I like.

Next, most CNC drivers can't handle splines, In QCAM these will be approximated by arc segments before exporting them as G-code.
See the tolerance setting for the Explode tool.
With a high fitpoints count one gets more tiny arc segments ... Even more with a minute tolerance. e_geek

Regards,
CVH