[Solved] Best way to create a toolpath from SVG paths?

Here's the place for discussion related to CAM/CNC and the development of the Path module.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
pathfinder
Posts: 315
Joined: Mon Oct 04, 2021 10:27 am

[Solved] Best way to create a toolpath from SVG paths?

Post by pathfinder »

Hello,

basically what the title says. I have an SVG and want to engrave the paths (so no faces, just lines). When I import the SVG, it separates all features/curves into individual paths, no matter what I did to them before(grouping, joining and so on).

I can take all the paths of the SVG, create a job for it and create an engraving operation just fine, but the problem is that it requires me to select all the paths individually and add it to the geometry.

Thing is, the SVG I'm about to work on has a ton of individual shapes (think like a cobblestone marketplace situation for a model) and this would mean that I'd have to individually select and add hundreds, possibly thousands of paths to the operation. Selecting multiple paths at once and adding them to the geometry doesn't work because the engraving task window only lets you select edges/paths of the same solid at one time and it's all considered individual solids.

So what I'm looking for here is a way to make this workflow happen. Is there a way to consolidate the individual SVG-paths to a single "solid" before using Path WB on it? Is there a different option?

I remember that there is a way to turn edges to gcode paths directly somewhere in the dropdown menu, but I have trouble finding it.


Version:

Code: Select all

OS: Arch Linux (XFCE/xfce)
Word size of FreeCAD: 64-bit
Version: 0.21.30256 (Git) AppImage
Build type: Release
Branch: master
Hash: 55866fd62221beadad3cfd60915278b156609a66
Python 3.10.6, Qt 5.15.4, Coin 4.0.0, Vtk 9.1.0, OCC 7.6.2
Locale: English/United States (en_US)

Looking forward to your inputs.


Edit:

Looks like I've found the answer myself for the most part.

- Use the Draft WBs Upgrade, then Downgrade to turn the paths into a single object.

- create a job for it.

- in the engraving dialog, remove the block object from the Base geometry.

- Box select everything.

- Add it to the geometry.

- Apply.

As it shows here, there seems to be a bit of an issue with the engraving OP recognizing edges/paths when they are not individually provided. I'm also still searching for the option to turn an edge into a toolpath 1:1, I remember using it once, but I don't remember how I got there.
Last edited by pathfinder on Mon Sep 12, 2022 11:55 pm, edited 1 time in total.
User avatar
pathfinder
Posts: 315
Joined: Mon Oct 04, 2021 10:27 am

Re: Best way to create a toolpath from SVG paths?

Post by pathfinder »

Update:

I just received the SVG and the Upgrade --> Downgrade operation won't create a single solid.

As before, I can create a Job just fine, but the Engraving operation requires me to add edges one by one, because

Code: Select all

Please select edges from a single solid
The SVG consist of thousands of edges. Adding them one by one is more or less infeasible.

Is there any other way? Is there an option to bypass the single solid requirement?

Is there maybe a way to select and add all relevant edges to an existing engraving job via python scripting?

Or is there even a different free program I could use to turn an SVG into gcode?
User avatar
sliptonic
Veteran
Posts: 3459
Joined: Tue Oct 25, 2011 10:46 pm
Location: Columbia, Missouri
Contact:

Re: Best way to create a toolpath from SVG paths?

Post by sliptonic »

I feel like a broken record.
Please upload a project file so we're on the same page.
User avatar
pathfinder
Posts: 315
Joined: Mon Oct 04, 2021 10:27 am

Re: Best way to create a toolpath from SVG paths?

Post by pathfinder »

Sorry, managed to build an example that should illustrate the issue. See below.
sliptonic wrote: Mon Sep 12, 2022 4:26 pm I feel like a broken record.
Please upload a project file so we're on the same page.
Last edited by pathfinder on Mon Sep 12, 2022 7:09 pm, edited 1 time in total.
User avatar
pathfinder
Posts: 315
Joined: Mon Oct 04, 2021 10:27 am

Re: Best way to create a toolpath from SVG paths?

Post by pathfinder »

OK here is an example that should illustrate the issue.

What I've done:

Imported SVG as geometry.

Draft --> Upgrade

Draft --> Downgrade

Selected all edges and created the job you see.

The original file contains probably a hundred times as many edges.

Yes, it is a messy file with overlaps and stuff. I didn't built the original file, a client did (That's also why I can't upload the original file; it is not mine and I can't share it). I'm trying to work with what has been sent to me.
Attachments
forum.svg
(24.66 KiB) Downloaded 30 times
forum.FCStd
(261.31 KiB) Downloaded 27 times
jbraun
Posts: 253
Joined: Fri Sep 18, 2020 5:41 pm

Re: Best way to create a toolpath from SVG paths?

Post by jbraun »

In Inkscape that svg just looks like a bunch of lines. intuition says I'm missing something.
In any case these are tool paths from the Gcodetools extension in Inkscape
forum_svg_gct.png
forum_svg_gct.png (28.6 KiB) Viewed 1491 times
For English help on youtube check out Joko Engineering or Mango Jelly Solutions.
Look for recent videos, this software is updated at a rapid pace.
User avatar
sliptonic
Veteran
Posts: 3459
Joined: Tue Oct 25, 2011 10:46 pm
Location: Columbia, Missouri
Contact:

Re: Best way to create a toolpath from SVG paths?

Post by sliptonic »

1) Select all your edges.
2) Go to the draft workbench and use the 'Draft to Sketch' tool to make them into a sketch (engrave likes to work on a single 2D object)
3) Select the sketch and create your job.
4) Create your engrave operation.
5) Verify results
2022-09-12_18-27.png
2022-09-12_18-27.png (51.39 KiB) Viewed 1476 times
6) (Optional) Buy your developer a beer.
User avatar
pathfinder
Posts: 315
Joined: Mon Oct 04, 2021 10:27 am

Re: Best way to create a toolpath from SVG paths?

Post by pathfinder »

sliptonic wrote: Mon Sep 12, 2022 11:29 pm 1) Select all your edges.
2) Go to the draft workbench and use the 'Draft to Sketch' tool to make them into a sketch (engrave likes to work on a single 2D object)
3) Select the sketch and create your job.
4) Create your engrave operation.
5) Verify result
6) (Optional) Buy your developer a beer.
Yup, worked brilliantly, thanks a lot.

To be quite honest, I found a way to generate Gcode from Inkscape directly in the mean time, but this code looks wayyy cleaner.

As for the buying beer part, I did sent some a while back, should be enough for a beer or two ;)
jbraun wrote: Mon Sep 12, 2022 10:58 pm In Inkscape that svg just looks like a bunch of lines. intuition says I'm missing something.
In any case these are tool paths from the Gcodetools extension in Inkscape
forum_svg_gct.png
It is missing something because it's just a quick sample file. I can't share the original file because it's not mine.

I gotta take a look at the gcodetools extension, because the one I found was age old unmaintained stuff that worked okay-ish, but gave out out of scale code and generating gcode right out of inkscape would actually be kinda nice sometimes.
User avatar
sliptonic
Veteran
Posts: 3459
Joined: Tue Oct 25, 2011 10:46 pm
Location: Columbia, Missouri
Contact:

Re: Best way to create a toolpath from SVG paths?

Post by sliptonic »

pathfinder wrote: Mon Sep 12, 2022 11:55 pm As for the buying beer part, I did sent some a while back, should be enough for a beer or two ;)
Don't underestimate my demand for beer and coffee! :lol:

Just kidding. I really do appreciate it.

To give this answer a little more context:

A Job can have any number of base objects, But when you select subelements from a base as the Base Geometry of the operation, it will only let you select from one job base. This is probably something that can be improved but it doesn't come up often.

So if you convert all the edges into a sketch and use the sketch as the job base, you can select any subset for the operation. In other words it isn't all or nothing.
jbraun
Posts: 253
Joined: Fri Sep 18, 2020 5:41 pm

Re: Best way to create a toolpath from SVG paths?

Post by jbraun »

pathfinder wrote: Mon Sep 12, 2022 11:55 pm missing something because it's just a quick sample file. I can't share the original file because it's not mine.
Ah, I pointed to Gcodetools because the file was very simple. The paths created are plunge-and-trace and many settings and manipulations are done in Inkscape itself.
The documentation is poor by any standard.

Update/ this extension is quite broken in inkscape 1.0 and newer. Too bad as it's handy when ramping and other niceties are not needed.
For English help on youtube check out Joko Engineering or Mango Jelly Solutions.
Look for recent videos, this software is updated at a rapid pace.
Post Reply