OpenSCAD import / importCSG: support for SVG?
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
OpenSCAD import / importCSG: support for SVG?
When importing OpenSCAD-models, importCSG.py only supports dxf as 2D-format.
Since FreeCAD already has an SVG-import: Would it be possible, to also support svg in importCSG.py?
Is there any plan to support this, or what would have to be done?
Then, it would be possible, to import extruded SVGs from OpenSCAD to FreeCAD.
Since FreeCAD already has an SVG-import: Would it be possible, to also support svg in importCSG.py?
Is there any plan to support this, or what would have to be done?
Then, it would be possible, to import extruded SVGs from OpenSCAD to FreeCAD.
-
- Veteran
- Posts: 2764
- Joined: Mon Feb 27, 2012 5:31 pm
Re: OpenSCAD import / importCSG: support for SVG?
OpenSCAD import of SVG requires the 2019 version and importCSG has not been updated to support that facility.r31415 wrote: ↑Fri Jan 08, 2021 8:36 pm When importing OpenSCAD-models, importCSG.py only supports dxf as 2D-format.
Since FreeCAD already has an SVG-import: Would it be possible, to also support svg in importCSG.py?
Is there any plan to support this, or what would have to be done?
Then, it would be possible, to import extruded SVGs from OpenSCAD to FreeCAD.
importCSG would need to have code added to import the SVG file to a FreeCAD Object.
Do you have a small test scad and svg that I could use to evaluate?
Re: OpenSCAD import / importCSG: support for SVG?
Thanks for your answer, and sorry that I haven't replied earlier.
I've attached a minimal example.
I would be very pleased, if FreeCAD could import CSG+SVG in the (near) future, and I'm willing to help, but I don't know the FreeCAD-codebase.
I've attached a minimal example.
I would be very pleased, if FreeCAD could import CSG+SVG in the (near) future, and I'm willing to help, but I don't know the FreeCAD-codebase.
- Attachments
-
- svg-test.csg
- CSG-file, exported by OpenSCAD, to be imported by FreeCAD
- (300 Bytes) Downloaded 29 times
-
- svg-test.svg
- SVG example
- (4.18 KiB) Downloaded 42 times
-
- svg-test.scad
- OpenSCAD with SVG
- (150 Bytes) Downloaded 38 times
Re: OpenSCAD import / importCSG: support for SVG?
This is on my radar for 0.20 as we work to make interoperability with OpenSCAD more robust. There are some glitches in the DXF code that need resolution as well.
-
- Veteran
- Posts: 2764
- Joined: Mon Feb 27, 2012 5:31 pm
Re: OpenSCAD import / importCSG: support for SVG?
Any updates on this? I have FreeCAD 0.20 but I wind up with:
when importing .csg to FreeCAD, where the .csg was exported from a .scad with a .svg import.
Code: Select all
File "/usr/lib/freecad/Mod/OpenSCAD/importCSG.py", line 866, in process_import_file
raise ValueError("Unsupported file extension %s" % ext)
<class 'ValueError'>: Unsupported file extension svg
Re: OpenSCAD import / importCSG: support for SVG?
No, this didn't happen for 0.20 (as you've discovered). It's still on the "someday to-do list", but if any other dev wants to have at it please go ahead!
-
- Veteran
- Posts: 2764
- Joined: Mon Feb 27, 2012 5:31 pm
Re: OpenSCAD import / importCSG: support for SVG?
For SVG FreeCAD uses sax
From importSVG.py
Wondering if there is a way to have it create a single object rather than insert n objects into a doc.
From importSVG.py
Code: Select all
# Set up the parser
parser = xml.sax.make_parser()
parser.setFeature(xml.sax.handler.feature_external_ges, False)
parser.setContentHandler(svgHandler())
parser._cont_handler.doc = doc
-
- Veteran
- Posts: 2764
- Joined: Mon Feb 27, 2012 5:31 pm
Re: OpenSCAD import / importCSG: support for SVG?
Okay I have added code to the Alternate OpenSCAD importer https://github.com/KeithSloan/OpenSCAD_Alt_Import
Remember with the Alternate importer you need to select open file - csg or scad file
Then you will be prompted as to which importer you wish to use.
Remember with the Alternate importer you need to select open file - csg or scad file
Then you will be prompted as to which importer you wish to use.
Re: OpenSCAD import / importCSG: support for SVG?
Did you get this resolved?keithsloan52 wrote: ↑Mon Aug 08, 2022 6:10 pm Wondering if there is a way to have it create a single object rather than insert n objects into a doc.