Is it Possible to get acttive FreeCAD App from extrenal Python consol?
I understand if i run something like this
Code: Select all
import FreeCAD
doc = FreeCAD.open(filename)
Can i acces to allready open FreeCAD?
Thank You!
Code: Select all
import FreeCAD
doc = FreeCAD.open(filename)
Code: Select all
freecad --single-instance /tmp/please_open_this.FCStd
# Opens the file in a new tab
Code: Select all
cat /tmp/please_run_this_script.py
print("hello nice to meet you Mrs FreeCAD instance!")
freecad --single-instance /tmp/please_run_this_script.py
# The report view of the existing instance shows "hello nice to meet you Mrs FreeCAD instance!"
Sorry you are not correct.
Code: Select all
import sys
# add folder containing FreeCAD.pyd, FreeCADGui.pyd to sys.path
#sys.path.append("C:/Program Files/FreeCAD 0.18/bin") # example for Windows
sys.path.append("/usr/lib/freecad-daily/lib") # example for Linux
sys.path.append("/usr/lib/freecad-daily/Mod") # example for Linux
#sys.path.append("/usr/lib/freecad/lib") # example for Linux
import FreeCAD
import FreeCADGui
import Part
import Draft
import Import
if len(sys.argv)<3:
print ("Usage: sys.argv[0] <in_file> <out_file>")
sys.exit(1)
iname=sys.argv[1]
oname=sys.argv[2]
print('Importing : '+iname)
FreeCAD.loadFile(iname)
# iterate through all objects
for o in App.ActiveDocument.Objects:
# find root object and export the shape
#print(dir(o))
#print(o.Name)
if o.TypeId == 'App::Part' :
#print(o.TypeId)
print('Exporting STEP file : '+oname)
print('This can be a very slow process')
print('for large files Please be patient')
#Import.export([o],"/tmp/test4.step")
Import.export([o],oname)
sys.exit(0)
sys.exit(0)
keithsloan52 wrote: ↑Thu Jan 28, 2021 7:53 pm Sorry you are not correct.
You can start FreeCAD with freecad -c from a command prompt.
You can also do things like
Your right. I just read the first line "Is it Possible to get acttive FreeCAD App from extrenal Python consol?"openBrain wrote: ↑Thu Jan 28, 2021 8:16 pmkeithsloan52 wrote: ↑Thu Jan 28, 2021 7:53 pm Sorry you are not correct.
You can start FreeCAD with freecad -c from a command prompt.
You can also do things like
The OP's question is 'Is it possible to get access to an existing running FreeCAD instance from another external Python console?'
Please tell me how what you wrote is a solution.
This said, reply from @suzanne.soy above doesn't answer the original question too. But OP said it works for him/her. So maybe I'm just blind guessing the question behind the question.keithsloan52 wrote: ↑Thu Jan 28, 2021 8:29 pm Your right. I just read the first line "Is it Possible to get acttive FreeCAD App from extrenal Python consol?"
which I don't think is very clear, I read it as he wanted to activate FreeCAD from the console.