FreeCAD sketch to OpenSCAD script
by Bror, published
I like the idea of constrained sketches available in FreeCAD. This is a hack to transfer them to OpenSCAD without too much trouble.
This Thing is an adaptation of Dan Newman's excellent Inkscape plugin (parent Thing). The main changes are:
1) Runs without input and saves .scad in the same folder as .svg file (see instructions below)
2) Does not extrude shapes, but keeps them two-dimensional
3) Ignores some transformations, and units, to get same size in OpenSCAD units as in the FreeCAD sketch.
4) Minor technical changes to circumvent ugly crash bugs in Inkscape (and FreeCAD's svg export, I think)
Recent Commentsview all
Liked Byview all
Give a Shout Out
Usage (outlined in attached images):
- Make sketch in FreeCAD,
- Export sketch as "Flattened SVG" under File -> Export,
(Windows) Run Inkscape plugin from context menu.
- (Other OS/Or don't want to install context menu) Run the following commandline
<pre>inkscape --verb=EditSelectAll --verb=SelectionCombine --verb=EditDeselect --verb=command.extrude.openscad_auto.noprefs --verb=EditUndo --verb=EditUndo --verb=FileQuit /full/path/to/file.svg</pre> This commandline opens your file in Inkscape, combines all paths and then runs the export plugin. The full path to file is important, it is used to determine the output directory for the SCAD file.
Prerequisites: Freecad, Inkscape
- Install Inkscape plugin (see parent thing by Dan Newman for details).
- (optional, but convenient) Make context menu, shell script or whatever you prefer to run inkscape from the commandline as per above.
To install a context menu in Windows 7 (like the one in attached image) I made .reg-file which installs the menu for svg-files, and runs Inkscape assuming it's installed at the default location. I attach this .reg file, <b>but</b> a) never trust a .reg-file from random internet people: check the contents yourself, and b) edit the file to match the location of your Inkscape.exe .
If you are not comfortable with .reg-files, there is a guide at http://www.howtogeek.com/107965/how-to-add-any-application-shortcut-to-windows-explorers-context-menu/ , make a command for "svgfile" which runs <pre>"c:[backslash]Program Files (x86)[backslash]Inkscape[backslash]inkscape.exe" --verb=EditSelectAll --verb=SelectionCombine --verb=EditDeselect --verb=command.extrude.openscad_auto.noprefs --verb=EditUndo --verb=EditUndo --verb=FileQuit "%1"</pre> (sorry for [backslash] -- thingiverse removes them automatically it seems)
This is very much a Work in Progress, and it has not been tested at all. It just happens to work on my machine, with my settings. It should probably do something to .svg's generated with other programs as well, feel free to try.