First thanks a lot for the software. It is greatly appreciated.
Second I know there exists other posts with the same topics but the truth is, those haven’t work for me.
Anyway I’m using FreeCAD version 0.19 in an ubuntu 20.04 with python 3.8.
I imagine that perhaps some solutions could change in the newer versions.
What I’m doing now is trying to get a picture from a freeCAD file using just a python script which is run from the ubuntu terminal (NOT the python console inside FreeCAD)
If I run this code I do get a image file with what I want.
Code: Select all
FREECADPATH= '/usr/lib/freecad-python3/lib'
import sys
sys.path.append(FREECADPATH)
import FreeCAD,FreeCADGui
FreeCADGui.showMainWindow()
import Part,PartGui
#doc = FreeCAD.newDocument()
doc =FreeCAD.openDocument('/path_to_file/name_file')
Gui.Selection.addSelection('name_file','Fusion') #FUsion in this case is the name of the feature which I select
Gui.runCommand('Std_ToggleVisibility',0)
box = doc.getObject("Fusion")
doc.recompute()
Gui.activeDocument().activeView().viewAxometric()
Gui.activeDocument().activeView().setAnimationEnabled(False)
Gui.SendMsgToActiveView("ViewFit")
Gui.Selection.clearSelection()
Gui.ActiveDocument.ActiveView.saveImage("/path_to_save_the_image/name_image.png",222,222,"White")
Besides I have another problem, I was thinking in trying to do a web app, and I will upload the code to an ubuntu server (that’s why I just want to use python code). What it seems to me is that the script actually opens FreeCAD and runs the code lines next to
Code: Select all
FreeCADGui.showMainWindow()
But I don’t know whether that is going to work in a server.
I’ve trying to use the code from this https://forum.freecadweb.org/viewtopic. ... e=1&t=1824 , (which is a windows solution) but didn’t work for me.
Right now I’m trying to read the documentation to use coin or PySide but the docs are not that straightforward.
If someone has managed to do this I would deeply appreciated