From 83bc0e922b5bd991598847cf6a3fcb4ad5b4cd54 Mon Sep 17 00:00:00 2001 From: Dawit Abate Date: Wed, 26 Jun 2019 13:24:09 +0300 Subject: [PATCH] Added searching methods for freecad libraries --- src/freecad_to_gazebo/__init__.py | 32 +++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/freecad_to_gazebo/__init__.py diff --git a/src/freecad_to_gazebo/__init__.py b/src/freecad_to_gazebo/__init__.py new file mode 100644 index 0000000..f4de801 --- /dev/null +++ b/src/freecad_to_gazebo/__init__.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python3 + +import os + +# check os types to search for freecad libraries +if 'posix' in os.name: + # TODO: Test the result of os.name in different systems + _so = os.popen('which freecad') + FREECAD_PATH = _so.readline().replace('\n', '') + if not FREECAD_PATH: + _so.close() + _so = os.popen('which FreeCAD') + FREECAD_PATH = _so.readline().replace('\n', '') + _so.close() + + FREECAD_PATH = FREECAD_PATH.replace('bin', 'lib') + + if not FREECAD_PATH: + raise ModuleNotFoundError('FreeCAD not installed.') + +elif 'nt' in os.name: + # TODO: Find freecad libs on windows + pass +else: + raise Exception("Platform not supported") + +# Extend sys.path to include freecad python libraries (including workbenches) +os.sys.path.extend(d.path for d in os.scandir(FREECAD_PATH)) + +from .exporter import export +from .model import * +