diff --git a/cnc25d/importing_freecad.py b/cnc25d/importing_freecad.py index ea5f893..b152665 100644 --- a/cnc25d/importing_freecad.py +++ b/cnc25d/importing_freecad.py @@ -47,28 +47,32 @@ def importing_freecad(): ''' This function looks for the FreeCAD library and import it if needed just call this function where you want to import FreeCAD ''' - # choose your favorite test to check if you are running with FreeCAD GUI or traditional Python - freecad_gui = True - #if not(FREECADPATH in sys.path): # test based on PYTHONPATH - if not("FreeCAD" in dir()): # test based on loaded module - freecad_gui = False - #print("dbg102: freecad_gui:", freecad_gui) - - if not(freecad_gui): - freecad_path='' - for p in FREECADPATH: - if(os.path.isfile("%s/FreeCAD.so"%(p))): - freecad_path=p - if(freecad_path==''): - print("ERR070: Error, the FreeCAD library path has not been found!") - print("Add the path of the directory containing FreeCAD.so to the variable FREECADPATH in the file {:s}".format(__FILE__)) - sys.exit(2) - #print("dbg101: add FREECADPATH to sys.path") - sys.path.append(freecad_path) - try: - import FreeCAD - except: - print("ERR080: Error, the FreeCAD library can not be imported by cnc25d!") + try: + import FreeCAD + return + except: + # choose your favorite test to check if you are running with FreeCAD GUI or traditional Python + freecad_gui = True + #if not(FREECADPATH in sys.path): # test based on PYTHONPATH + if not("FreeCAD" in dir()): # test based on loaded module + freecad_gui = False + #print("dbg102: freecad_gui:", freecad_gui) + + if not(freecad_gui): + freecad_path='' + for p in FREECADPATH: + if(os.path.isfile("%s/FreeCAD.so"%(p))): + freecad_path=p + if(freecad_path==''): + print("ERR070: Error, the FreeCAD library path has not been found!") + print("Add the path of the directory containing FreeCAD.so to the variable FREECADPATH in the file {:s}".format(__FILE__)) + sys.exit(2) + #print("dbg101: add FREECADPATH to sys.path") + sys.path.append(freecad_path) + try: + import FreeCAD + except: + print("ERR080: Error, the FreeCAD library can not be imported by cnc25d!") sys.exit(2) ################################################################