Code: Select all
# mesh
# Source: https://forum.freecadweb.org/viewtopic.php?t=29719
# make the femmeshgmsh object
ObjectsFem.makeMeshGmsh(FreeCAD.ActiveDocument, 'FEMMeshGmsh')
# femmeshgmsh is now the active object, set its Part property to the cube
FreeCAD.ActiveDocument.ActiveObject.Part = FreeCAD.ActiveDocument.Body
obj = FreeCAD.ActiveDocument.ActiveObject
# make the task dialog, but don't show it
from femguiobjects import _ViewProviderFemMeshGmsh
taskd = _ViewProviderFemMeshGmsh._TaskPanelFemMeshGmsh(obj)
# set the task dialog's object property to the femmeshgmsh object
taskd.obj = obj
# call the method that gets called when the user clicks Apply button
taskd.run_gmsh()
# Put mesh into analysis object
App.getDocument("Unnamed").getObject("Analysis").addObject(App.getDocument("Unnamed").getObject("FEMMeshGmsh"))
App.ActiveDocument.recompute()
which works very nicely in the GUI, but when I try it in the command line, I get
This is because the _ViewProviderFemMeshGmsh class needs FemGui as can bee seen in the source code: https://github.com/FreeCAD/FreeCAD/blob ... eshGmsh.py"Cannot load Gui module in console application."
Do you see any workaround?