I want to use FreeCAD with python without launching the graphical interface.
Here is a piece of code (which doesn't work in my case...)
Code: Select all
import sys
FREECADPATH = "C:/Program Files/FreeCAD 0.16/bin/"
sys.path.append(FREECADPATH)
import FreeCAD as App
import FreeCADGui as Gui
doc = App.ActiveDocument
gui_doc = Gui.ActiveDocument
gui_doc.activateWorkbench("myWorkbench")
gui_doc = Gui.ActiveDocument
AttributeError: 'module' object has no attribute 'ActiveDocument'
And indeed, when I look at what FreeCADGui offers me :
Code: Select all
print(dir(Gui))
['__doc__', '__file__', '__name__', '__package__', 'embedToWindow', 'exec_loop',
'setupWithoutGUI', 'showMainWindow']
What do I need to do to be able to use FreeCADGui as from the FreeCAD GUI?
Environment tested:
OS: Windows 7 64-bit
FreeCAD Version: 0.16
Python version: 2.7.16
---------------------------
OS: Windows 10 64-bit
FreeCAD Version: 0.18
Python version: 3.7
Thank you in advance.