Note - I'm not running a script in the python console inside FreeCAD. This is all in a python script in a docker container with FreeCAD installed.
I'm trying to make an SVG of a page generated by FreeCAD running in a python script. I have views of a shape no problem, but cannot figure out how to add dimensions AND save to an SVG. There are a couple options that get close as far as I can tell...
- Using the older Drawing module (and drawing_dimensioning):
I can make an SVG of a page with views of my shape, but cannot add dimensions. The module drawing_dimensioning is perfect if I was using full GUI FreeCAD. I cannot seem to use this module from the python script however. When I import it, I get the following error:
File "/usr/lib/freecad/Mod/drawingDimensioning/core.py", line 184, in <module>
FreeCADGui.addCommand('dd_help', helpCommand())
AttributeError: 'module' object has no attribute 'addCommand'
I've tried many of the fixes for this error, but cannot find any solutions that work. Does this have something to do with drawingDimensioning having FreeCADGui as a dependency? is FreeCADGui missing addCommand()? If you know of another approach, please comment.
- The newer TechDraw module:
As far as I can tell this works (although with fewer features than drawing_dimensioning). BUT I cannot use the module TechDrawGui from the command line. The TechDrawGui module is required for saving a TechDraw page to SVG. I get this error when I do:
File "/app/main_process.py", line 14, in <module>
import Part, Drawing, FreeCADGui, TechDrawGui
ImportError: Cannot load Gui module in console application.
I CAN however import FreeCADGui module without any problems. Importing and Using the TechDraw module seems fine too.
Thanks for reading. If you think you have a method of creating dimensions on a page and saving as SVG all from python, please let me know!