Code for importing svg into cad query

108 views
Skip to first unread message

Dov Grobgeld

unread,
Mar 10, 2024, 1:55:35 AMMar 10
to CadQuery
Hello,

Based on my Bézier pull request https://github.com/CadQuery/cadquery/pull/1529 and the python library svgpathtools, I wrote a small adapter for importing a svg path into cadquery.

Here's a screenshot:

fs.png
The code is available at:


Please let me know your thoughts!

Regards,

Jeremy Wright

unread,
Mar 12, 2024, 6:49:45 AMMar 12
to Dov Grobgeld, CadQuery
Very nice. I put some things like this, which require new one-off dependencies, in the plugins repo. Plugins can still be installed individually from the repo, so users can pick and choose which functionality to add to CadQuery.


--
cadquery home: https://github.com/CadQuery/cadquery
post issues at https://github.com/CadQuery/cadquery/issues
run it at home at : https://github.com/CadQuery/CQ-editor
---
You received this message because you are subscribed to the Google Groups "CadQuery" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cadquery+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cadquery/CA%2B%2BfsGHf1VdnmsAzNpCC%2BBFwiOeMxB4mgGyObFADO0YjRTJN-A%40mail.gmail.com.

Dov Grobgeld

unread,
Mar 12, 2024, 2:16:34 PMMar 12
to Jeremy Wright, CadQuery
Thanks for the feedback Jeremy and for the tip about the cadquery plugins!

I'm pondering whether it is worth just loading a single svg path or whether I should at least add support for recursive transformations and some of the SVG primitive geometric types? Perhaps I'll initially write a plugin for a single svg path, and if and when I get around to it, write another plugin that includes more features from a complete SVG file.

Regards,

Diego Aguilera

unread,
Apr 15, 2024, 10:28:24 AMApr 15
to CadQuery
Dov! Thanks for this contribution. I'll ask my question first since I'm not sure if it's related to your code. It could just be how CadQuery works. I have a couple of comments specific to your code below.

Question:
I've used Dov's code to import an SVG with multiple paths and extrude them. I want to join them to a simple box. I have tried creating the box first and then extruding the SVG from a face. And extruding the SVG, creating a BoundBox, rectangle, and extruding it. Both result in the same error message. 

I've attached the error message. The translate is to overlap the box and SVG. Dov code to convert the SVG Paths to Wires (?) works as expected.

Dov:
Your fish example is very simple. Having attempted this in the past, I've learned most SVGs are more complex since most of the time they're being created using some kind of program with a UI. While processing various SVGs I kept getting an error. Turns out there are two points in the file that are the same. I ended up writing a small function that checks points to make sure they're not the same within a tolerance. See GIST: https://gist.github.com/aguileraGit/d6013c66a5822a312056f737b85738f6

My other comment/request are other SVG elements that aren't paths. Any plans to add other non-paths SVG elements (circles, rectangles, maybe non-path lines)? Happy to contribute. I almost feel this could/should be it's own repo (plugin).
Screenshot from 2024-04-15 09-11-13.png
Screenshot from 2024-04-15 09-04-34.png
Reply all
Reply to author
Forward
0 new messages