diff --git a/src/Mod/BIM/nativeifc/ifc_classification.py b/src/Mod/BIM/nativeifc/ifc_classification.py index 0115ebe865..18de9a170f 100644 --- a/src/Mod/BIM/nativeifc/ifc_classification.py +++ b/src/Mod/BIM/nativeifc/ifc_classification.py @@ -21,7 +21,7 @@ # *************************************************************************** -from nativeifc import ifc_tools # lazy import +from . import ifc_tools # lazy import def edit_classification(obj): diff --git a/src/Mod/BIM/nativeifc/ifc_commands.py b/src/Mod/BIM/nativeifc/ifc_commands.py index 2fb24fcf30..25591cdc01 100644 --- a/src/Mod/BIM/nativeifc/ifc_commands.py +++ b/src/Mod/BIM/nativeifc/ifc_commands.py @@ -25,7 +25,7 @@ import FreeCAD import FreeCADGui -from nativeifc import ifc_openshell +from . import ifc_openshell translate = FreeCAD.Qt.translate QT_TRANSLATE_NOOP = FreeCAD.Qt.QT_TRANSLATE_NOOP @@ -34,7 +34,7 @@ QT_TRANSLATE_NOOP = FreeCAD.Qt.QT_TRANSLATE_NOOP def get_project(): """Gets the current project""" - from nativeifc import ifc_tools + from . import ifc_tools if FreeCADGui.Selection.getSelection(): return ifc_tools.get_project(FreeCADGui.Selection.getSelection()[0]) @@ -57,7 +57,7 @@ class IFC_Diff: } def Activated(self): - from nativeifc import ifc_diff + from . import ifc_diff proj = get_project() if proj: @@ -88,8 +88,8 @@ class IFC_Expand: no = obj.ViewObject.Proxy.expandChildren(obj) ns.extend(no) else: - from nativeifc import ifc_generator - from nativeifc import ifc_tools + from . import ifc_generator + from . import ifc_tools document = FreeCAD.ActiveDocument ifc_generator.delete_ghost(document) @@ -130,7 +130,7 @@ class IFC_ConvertDocument: translate("BIM", "The active document is already an IFC document") ) else: - from nativeifc import ifc_tools + from . import ifc_tools ifc_tools.convert_document(doc) @@ -154,7 +154,7 @@ class IFC_MakeProject: def Activated(self): from importers import exportIFC # lazy loading - from nativeifc import ifc_tools + from . import ifc_tools from PySide import QtCore, QtGui doc = FreeCAD.ActiveDocument @@ -196,7 +196,7 @@ class IFC_Save: return False def Activated(self): - from nativeifc import ifc_tools # lazy loading + from . import ifc_tools # lazy loading doc = FreeCAD.ActiveDocument if getattr(doc, "IfcFilePath", None): @@ -231,8 +231,8 @@ class IFC_SaveAs: return False def Activated(self): - from nativeifc import ifc_tools # lazy loading - from nativeifc import ifc_viewproviders + from . import ifc_tools # lazy loading + from . import ifc_viewproviders doc = FreeCAD.ActiveDocument if ifc_viewproviders.get_filepath(doc): diff --git a/src/Mod/BIM/nativeifc/ifc_diff.py b/src/Mod/BIM/nativeifc/ifc_diff.py index 2becf39d02..43cf4822be 100644 --- a/src/Mod/BIM/nativeifc/ifc_diff.py +++ b/src/Mod/BIM/nativeifc/ifc_diff.py @@ -26,7 +26,7 @@ import difflib import FreeCAD import FreeCADGui import ifcopenshell -from nativeifc import ifc_tools +from . import ifc_tools import Arch_rc translate = FreeCAD.Qt.translate diff --git a/src/Mod/BIM/nativeifc/ifc_export.py b/src/Mod/BIM/nativeifc/ifc_export.py index ba81c6d5fd..91001de2df 100644 --- a/src/Mod/BIM/nativeifc/ifc_export.py +++ b/src/Mod/BIM/nativeifc/ifc_export.py @@ -30,8 +30,8 @@ from importers import exportIFC from importers import exportIFCHelper from importers import importIFCHelper -from nativeifc import ifc_tools -from nativeifc import ifc_import +from . import ifc_tools +from . import ifc_import PARAMS = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/NativeIFC") diff --git a/src/Mod/BIM/nativeifc/ifc_generator.py b/src/Mod/BIM/nativeifc/ifc_generator.py index 15731ec650..4c01bf2501 100644 --- a/src/Mod/BIM/nativeifc/ifc_generator.py +++ b/src/Mod/BIM/nativeifc/ifc_generator.py @@ -25,20 +25,23 @@ The only entry point in this module is the generate_geometry() function which is used by the execute() method of ifc_objects""" -import time import re import FreeCAD from FreeCAD import Base import Part + import ifcopenshell -from ifcopenshell.util import element -from nativeifc import ifc_tools -from nativeifc import ifc_export +import ifcopenshell.util.element + import multiprocessing + import FreeCADGui + from pivy import coin from PySide import QtCore +from . import ifc_tools +from . import ifc_export def generate_geometry(obj, cached=False): """Sets the geometry of the given object from a corresponding IFC element. diff --git a/src/Mod/BIM/nativeifc/ifc_geometry.py b/src/Mod/BIM/nativeifc/ifc_geometry.py index 5257099c8c..1cdda68be9 100644 --- a/src/Mod/BIM/nativeifc/ifc_geometry.py +++ b/src/Mod/BIM/nativeifc/ifc_geometry.py @@ -22,11 +22,12 @@ """This module contains geometry editing and geometry properties-related tools""" - import FreeCAD + import ifcopenshell -from ifcopenshell.util import unit -from nativeifc import ifc_tools +import ifcopenshell.util.unit + +from . import ifc_tools def add_geom_properties(obj): diff --git a/src/Mod/BIM/nativeifc/ifc_import.py b/src/Mod/BIM/nativeifc/ifc_import.py index 007dfa3272..5a51801e28 100644 --- a/src/Mod/BIM/nativeifc/ifc_import.py +++ b/src/Mod/BIM/nativeifc/ifc_import.py @@ -20,20 +20,20 @@ # * * # *************************************************************************** -import importlib import os import time import FreeCAD -from nativeifc import ifc_tools -from nativeifc import ifc_psets -from nativeifc import ifc_materials -from nativeifc import ifc_layers -from nativeifc import ifc_status + +from . import ifc_tools +from . import ifc_psets +from . import ifc_materials +from . import ifc_layers +from . import ifc_status if FreeCAD.GuiUp: import FreeCADGui - import Arch_rc + import Arch_rc # needed to load the Arch icons, noqa: F401 PARAMS = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/NativeIFC") @@ -79,7 +79,7 @@ def insert( stime = time.time() try: document = FreeCAD.getDocument(docname) - except: + except NameError: document = FreeCAD.newDocument() if singledoc is None: singledoc = PARAMS.GetBool("SingleDoc", True) @@ -145,7 +145,6 @@ def get_options(strategy=None, shapemode=None, switchwb=None, silent=False): ask = PARAMS.GetBool("AskAgain", False) if ask and FreeCAD.GuiUp: import FreeCADGui - from PySide import QtGui dlg = FreeCADGui.PySideUic.loadUi(":/ui/dialogImport.ui") dlg.checkSwitchWB.hide() # TODO see what to do with this... @@ -188,7 +187,6 @@ def get_project_type(silent=False): return ptype if ask and FreeCAD.GuiUp: import FreeCADGui - from PySide import QtGui dlg = FreeCADGui.PySideUic.loadUi(":/ui/dialogCreateProject.ui") result = dlg.exec_() @@ -202,16 +200,15 @@ def get_project_type(silent=False): # convenience functions def toggle_lock_on(): - ifc_status.on_toggle_lock(True, noconvert=True, setchecked=True) -def toggle_lock_off(): +def toggle_lock_off(): ifc_status.on_toggle_lock(False, noconvert=True, setchecked=True) -def unset_modified(): +def unset_modified(): try: FreeCADGui.ActiveDocument.Modified = False - except: + except AttributeError: pass diff --git a/src/Mod/BIM/nativeifc/ifc_layers.py b/src/Mod/BIM/nativeifc/ifc_layers.py index 2ab4b5a82a..f4fa9ab0dc 100644 --- a/src/Mod/BIM/nativeifc/ifc_layers.py +++ b/src/Mod/BIM/nativeifc/ifc_layers.py @@ -23,11 +23,10 @@ """This NativeIFC module deals with layers""" -from nativeifc import ifc_tools import ifcopenshell -from ifcopenshell import util -from ifcopenshell.util import element +import ifcopenshell.util.element +from . import ifc_tools def load_layers(obj): """Loads all the layers of an IFC file""" diff --git a/src/Mod/BIM/nativeifc/ifc_materials.py b/src/Mod/BIM/nativeifc/ifc_materials.py index 2bffd72760..e925116a26 100644 --- a/src/Mod/BIM/nativeifc/ifc_materials.py +++ b/src/Mod/BIM/nativeifc/ifc_materials.py @@ -22,13 +22,12 @@ """This NativeIFC module deals with materials""" - import FreeCAD -from nativeifc import ifc_tools -import ifcopenshell -from ifcopenshell import util -from ifcopenshell.util import element +import ifcopenshell +import ifcopenshell.util.element + +from . import ifc_tools def create_material(element, parent, recursive=False): """Creates a material object in the given project or parent material""" diff --git a/src/Mod/BIM/nativeifc/ifc_objects.py b/src/Mod/BIM/nativeifc/ifc_objects.py index be202c7012..c3350dab3e 100644 --- a/src/Mod/BIM/nativeifc/ifc_objects.py +++ b/src/Mod/BIM/nativeifc/ifc_objects.py @@ -120,7 +120,7 @@ class ifc_object: def rebuild_classlist(self, obj, setprops=False): """rebuilds the list of Class enum property according to current class""" - from nativeifc import ifc_tools # lazy import + from . import ifc_tools # lazy import obj.Class = [obj.IfcClass] obj.Class = ifc_tools.get_ifc_classes(obj, obj.IfcClass) @@ -144,7 +144,7 @@ class ifc_object: return None def execute(self, obj): - from nativeifc import ifc_generator # lazy import + from . import ifc_generator # lazy import if obj.isDerivedFrom("Part::Feature"): cached = getattr(self, "cached", False) @@ -167,7 +167,7 @@ class ifc_object: def edit_attribute(self, obj, attribute, value=None): """Edits an attribute of an underlying IFC object""" - from nativeifc import ifc_tools # lazy import + from . import ifc_tools # lazy import if not value: value = obj.getPropertyByName(attribute) @@ -182,8 +182,8 @@ class ifc_object: def edit_annotation(self, obj, attribute, value=None): """Edits an attribute of an underlying IFC annotation""" - from nativeifc import ifc_tools # lazy import - from nativeifc import ifc_export + from . import ifc_tools # lazy import + from . import ifc_export if not value: if hasattr(obj, attribute): @@ -239,8 +239,8 @@ class ifc_object: def edit_geometry(self, obj, prop): """Edits a geometry property of an object""" - from nativeifc import ifc_geometry # lazy loading - from nativeifc import ifc_tools # lazy import + from . import ifc_geometry # lazy loading + from . import ifc_tools # lazy import result = ifc_geometry.set_geom_property(obj, prop) if result: @@ -249,7 +249,7 @@ class ifc_object: def edit_schema(self, obj, schema): """Changes the schema of an IFC document""" - from nativeifc import ifc_tools # lazy import + from . import ifc_tools # lazy import ifcfile = ifc_tools.get_ifcfile(obj) if not ifcfile: @@ -275,22 +275,22 @@ class ifc_object: def edit_placement(self, obj): """Syncs the internal IFC placement""" - from nativeifc import ifc_tools # lazy import + from . import ifc_tools # lazy import ifc_tools.set_placement(obj) def edit_pset(self, obj, prop): """Edits a Pset value""" - from nativeifc import ifc_psets # lazy import + from . import ifc_psets # lazy import ifc_psets.edit_pset(obj, prop) def edit_group(self, obj): """Edits the children list""" - from nativeifc import ifc_tools # lazy import - from nativeifc import ifc_layers + from . import ifc_tools # lazy import + from . import ifc_layers if obj.Class in [ "IfcPresentationLayerAssignment", @@ -321,7 +321,7 @@ class ifc_object: def edit_type(self, obj): """Edits the type of this object""" - from nativeifc import ifc_types # lazy import + from . import ifc_types # lazy import ifc_types.edit_type(obj) @@ -332,7 +332,7 @@ class ifc_object: def get_section_data(self, obj): """Returns two things: a list of objects and a cut plane""" - from nativeifc import ifc_tools # lazy import + from . import ifc_tools # lazy import import Part if not obj.IfcClass == "IfcAnnotation": @@ -375,7 +375,7 @@ class ifc_object: def edit_classification(self, obj): """Edits the classification of this object""" - from nativeifc import ifc_classification # lazy loading + from . import ifc_classification # lazy loading ifc_classification.edit_classification(obj) diff --git a/src/Mod/BIM/nativeifc/ifc_observer.py b/src/Mod/BIM/nativeifc/ifc_observer.py index 2aa933d905..f650c91101 100644 --- a/src/Mod/BIM/nativeifc/ifc_observer.py +++ b/src/Mod/BIM/nativeifc/ifc_observer.py @@ -23,7 +23,6 @@ """Document observer to act on documents containing NativeIFC objects""" -import os import FreeCAD params = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/NativeIFC") @@ -67,7 +66,7 @@ class ifc_observer: def slotDeletedObject(self, obj): """Deletes the corresponding object in the IFC document""" - from nativeifc import ifc_tools # lazy loading + from . import ifc_tools # lazy loading proj = ifc_tools.get_project(obj) if not proj: @@ -82,11 +81,10 @@ class ifc_observer: """Watch document IFC properties""" # only look at locked IFC documents - if not "IfcFilePath" in doc.PropertiesList: + if "IfcFilePath" not in doc.PropertiesList: return - from nativeifc import ifc_tools # lazy import - from nativeifc import ifc_status + from . import ifc_tools # lazy import if prop == "Schema": schema = doc.Schema @@ -126,13 +124,13 @@ class ifc_observer: def slotActivateDocument(self, doc): """Check if we need to lock""" - from nativeifc import ifc_status + from . import ifc_status ifc_status.on_activate() def slotRemoveDynamicProperty(self, obj, prop): - from nativeifc import ifc_psets + from . import ifc_psets ifc_psets.remove_property(obj, prop) # implementation methods @@ -164,8 +162,8 @@ class ifc_observer: if obj.Modified: projects.append(obj) if projects: - from nativeifc import ifc_tools # lazy loading - from nativeifc import ifc_viewproviders + from . import ifc_tools # lazy loading + from . import ifc_viewproviders ask = params.GetBool("AskBeforeSaving", True) if ask and FreeCAD.GuiUp: @@ -208,8 +206,8 @@ class ifc_observer: or "IfcType" in obj.PropertiesList \ or "CreateSpreadsheet" in obj.PropertiesList: FreeCAD.Console.PrintLog("Converting " + obj.Label + " to IFC\n") - from nativeifc import ifc_geometry # lazy loading - from nativeifc import ifc_tools # lazy loading + from . import ifc_geometry # lazy loading + from . import ifc_tools # lazy loading newobj = ifc_tools.aggregate(obj, doc) ifc_geometry.add_geom_properties(newobj) diff --git a/src/Mod/BIM/nativeifc/ifc_performance_test.py b/src/Mod/BIM/nativeifc/ifc_performance_test.py index 0e0b6ec049..7fb7740cd1 100644 --- a/src/Mod/BIM/nativeifc/ifc_performance_test.py +++ b/src/Mod/BIM/nativeifc/ifc_performance_test.py @@ -24,7 +24,7 @@ import os import time import FreeCAD import unittest -from nativeifc import ifc_import +from . import ifc_import FILES = [ diff --git a/src/Mod/BIM/nativeifc/ifc_psets.py b/src/Mod/BIM/nativeifc/ifc_psets.py index 472a751e32..bc4d993690 100644 --- a/src/Mod/BIM/nativeifc/ifc_psets.py +++ b/src/Mod/BIM/nativeifc/ifc_psets.py @@ -25,8 +25,10 @@ import os import re + import FreeCAD -from nativeifc import ifc_tools + +from . import ifc_tools translate = FreeCAD.Qt.translate @@ -361,7 +363,7 @@ def read_properties_conversion(): def remove_property(obj, prop): """Removes a custom property""" - from nativeifc import ifc_tools + from . import ifc_tools ifcfile = ifc_tools.get_ifcfile(obj) if not ifcfile: return diff --git a/src/Mod/BIM/nativeifc/ifc_selftest.py b/src/Mod/BIM/nativeifc/ifc_selftest.py index bad6568d12..25300dd909 100644 --- a/src/Mod/BIM/nativeifc/ifc_selftest.py +++ b/src/Mod/BIM/nativeifc/ifc_selftest.py @@ -29,14 +29,14 @@ import FreeCAD import Draft import Arch import unittest -from nativeifc import ifc_import -from nativeifc import ifc_tools -from nativeifc import ifc_geometry -from nativeifc import ifc_materials -from nativeifc import ifc_layers -from nativeifc import ifc_psets -from nativeifc import ifc_objects -from nativeifc import ifc_generator +from . import ifc_import +from . import ifc_tools +from . import ifc_geometry +from . import ifc_materials +from . import ifc_layers +from . import ifc_psets +from . import ifc_objects +from . import ifc_generator import ifcopenshell from ifcopenshell.util import element import difflib @@ -301,7 +301,7 @@ class NativeIFCTest(unittest.TestCase): self.assertTrue(obj.Shape.Volume > 1500000, "ChangeGeometry failed") def test12_RemoveObject(self): - from nativeifc import ifc_observer + from . import ifc_observer ifc_observer.add_observer() FreeCAD.Console.PrintMessage("NativeIFC 12: Remove object...") clearObjects() diff --git a/src/Mod/BIM/nativeifc/ifc_status.py b/src/Mod/BIM/nativeifc/ifc_status.py index 14d36894e8..a75375b509 100644 --- a/src/Mod/BIM/nativeifc/ifc_status.py +++ b/src/Mod/BIM/nativeifc/ifc_status.py @@ -101,7 +101,7 @@ def on_add_property(): if not sel: return from PySide import QtCore, QtGui # lazy loading - from nativeifc import ifc_psets + from . import ifc_psets obj = sel[0] psets = list(set([obj.getGroupOfProperty(p) for p in obj.PropertiesList])) psets = [p for p in psets if p] @@ -180,7 +180,7 @@ def on_add_pset(): if not sel: return from PySide import QtCore, QtGui # lazy loading - from nativeifc import ifc_psets + from . import ifc_psets obj = sel[0] mw = FreeCADGui.getMainWindow() # read standard psets @@ -328,7 +328,7 @@ def set_button(checked=False, setchecked=False): def unlock_document(): """Unlocks the active document""" - from nativeifc import ifc_tools # lazy loading + from . import ifc_tools # lazy loading doc = FreeCAD.ActiveDocument if not doc: @@ -356,10 +356,10 @@ def unlock_document(): def lock_document(): """Locks the active document""" - from nativeifc import ifc_tools # lazy loading + from . import ifc_tools # lazy loading from importers import exportIFC - from nativeifc import ifc_geometry - from nativeifc import ifc_export + from . import ifc_geometry + from . import ifc_export from PySide import QtCore doc = FreeCAD.ActiveDocument diff --git a/src/Mod/BIM/nativeifc/ifc_tools.py b/src/Mod/BIM/nativeifc/ifc_tools.py index 27ac90e750..e48754a6c4 100644 --- a/src/Mod/BIM/nativeifc/ifc_tools.py +++ b/src/Mod/BIM/nativeifc/ifc_tools.py @@ -33,14 +33,13 @@ translate = FreeCAD.Qt.translate try: import ifcopenshell - from ifcopenshell import geom - from ifcopenshell import api - from ifcopenshell import template - from ifcopenshell.util import element - from ifcopenshell.util import attribute - from ifcopenshell.util import schema - from ifcopenshell.util import placement - from ifcopenshell.util import unit + import ifcopenshell.api + import ifcopenshell.geom + import ifcopenshell.util.attribute + import ifcopenshell.util.element + import ifcopenshell.util.placement + import ifcopenshell.util.schema + import ifcopenshell.util.unit except ImportError as e: import FreeCAD FreeCAD.Console.PrintError( @@ -52,13 +51,13 @@ except ImportError as e: ) raise e -from nativeifc import ifc_objects -from nativeifc import ifc_viewproviders -from nativeifc import ifc_import -from nativeifc import ifc_layers -from nativeifc import ifc_status -from nativeifc import ifc_export -from nativeifc import ifc_psets +from . import ifc_objects +from . import ifc_viewproviders +from . import ifc_import +from . import ifc_layers +from . import ifc_status +from . import ifc_export +from . import ifc_psets from draftviewproviders import view_layer import ArchBuildingPart @@ -134,7 +133,7 @@ def convert_document(document, filename=None, shapemode=0, strategy=0, silent=Fa 3 = no children """ - if not "Proxy" in document.PropertiesList: + if "Proxy" not in document.PropertiesList: document.addProperty("App::PropertyPythonObject", "Proxy") document.setPropertyStatus("Proxy", "Transient") document.Proxy = ifc_objects.document_object() @@ -161,9 +160,9 @@ def setup_project(proj, filename, shapemode, silent): full = False d = "The path to the linked IFC file" - if not "IfcFilePath" in proj.PropertiesList: + if "IfcFilePath" not in proj.PropertiesList: proj.addProperty("App::PropertyFile", "IfcFilePath", "Base", d) - if not "Modified" in proj.PropertiesList: + if "Modified" not in proj.PropertiesList: proj.addProperty("App::PropertyBool", "Modified", "Base") proj.setPropertyStatus("Modified", "Hidden") if filename: @@ -181,7 +180,7 @@ def setup_project(proj, filename, shapemode, silent): # In IFC4, history is optional. What should we do here? proj.Proxy.ifcfile = ifcfile add_properties(proj, ifcfile, project, shapemode=shapemode) - if not "Schema" in proj.PropertiesList: + if "Schema" not in proj.PropertiesList: proj.addProperty("App::PropertyEnumeration", "Schema", "Base") # bug in FreeCAD - to avoid a crash, pre-populate the enum with one value proj.Schema = [ifcfile.wrapped_data.schema_name()] @@ -321,7 +320,7 @@ def create_children( def create_child(parent, element): subresult = [] # do not create if a child with same stepid already exists - if not element.id() in [ + if element.id() not in [ getattr(c, "StepId", 0) for c in get_parent_objects(parent) ]: doc = getattr(parent, "Document", parent) @@ -1581,8 +1580,8 @@ def get_orphan_elements(ifcfile): ] # add control elements proj = ifcfile.by_type("IfcProject")[0] - for rel in proj.Declares: - for ctrl in getattr(rel,"RelatedDefinitions", []): + for rel in getattr(proj, "Declares", []): + for ctrl in getattr(rel, "RelatedDefinitions", []): if ctrl.is_a("IfcControl"): products.append(ctrl) groups = [] @@ -1662,7 +1661,7 @@ def remove_tree(objs): nobjs = objs for obj in objs: for child in obj.OutListRecursive: - if not child in nobjs: + if child not in nobjs: nobjs.append(child) deletelist = [] for obj in nobjs: diff --git a/src/Mod/BIM/nativeifc/ifc_tree.py b/src/Mod/BIM/nativeifc/ifc_tree.py index cbfa923c8b..334e3e1931 100644 --- a/src/Mod/BIM/nativeifc/ifc_tree.py +++ b/src/Mod/BIM/nativeifc/ifc_tree.py @@ -79,7 +79,7 @@ def show_geometry_tree(element): import Arch_rc import FreeCADGui # lazy import - from nativeifc import ifc_tools + from . import ifc_tools from PySide import QtGui, QtWidgets if isinstance(element, FreeCAD.DocumentObject): @@ -146,7 +146,7 @@ def show_properties(current, previous): """Displays object properties""" import FreeCADGui - from nativeifc import ifc_tools # lazy loading + from . import ifc_tools # lazy loading from PySide import QtCore, QtGui, QtWidgets ifcid = int(current.text(0).split("=", 1)[0].strip(" ").strip("#")) diff --git a/src/Mod/BIM/nativeifc/ifc_types.py b/src/Mod/BIM/nativeifc/ifc_types.py index 0a714fa6d5..295d3cc8dd 100644 --- a/src/Mod/BIM/nativeifc/ifc_types.py +++ b/src/Mod/BIM/nativeifc/ifc_types.py @@ -24,7 +24,7 @@ import FreeCAD -from nativeifc import ifc_tools +from . import ifc_tools translate = FreeCAD.Qt.translate diff --git a/src/Mod/BIM/nativeifc/ifc_viewproviders.py b/src/Mod/BIM/nativeifc/ifc_viewproviders.py index 3487c34460..13f0c6bd43 100644 --- a/src/Mod/BIM/nativeifc/ifc_viewproviders.py +++ b/src/Mod/BIM/nativeifc/ifc_viewproviders.py @@ -82,10 +82,10 @@ class ifc_vp_object: return [] def setupContextMenu(self, vobj, menu): - from nativeifc import ifc_tools # lazy import - from nativeifc import ifc_psets - from nativeifc import ifc_materials - from nativeifc import ifc_types + from . import ifc_tools # lazy import + from . import ifc_psets + from . import ifc_materials + from . import ifc_types from PySide import QtCore, QtGui # lazy import if FreeCADGui.activeWorkbench().name() != 'BIMWorkbench': @@ -164,7 +164,7 @@ class ifc_vp_object: def hasChildren(self, obj): """Returns True if this IFC object can be decomposed""" - from nativeifc import ifc_tools # lazy import + from . import ifc_tools # lazy import ifcfile = ifc_tools.get_ifcfile(obj) if ifcfile: @@ -174,7 +174,7 @@ class ifc_vp_object: def expandChildren(self, obj=None): """Creates children of this object""" - from nativeifc import ifc_tools # lazy import + from . import ifc_tools # lazy import from PySide import QtCore, QtGui if not obj: @@ -260,14 +260,14 @@ class ifc_vp_object: def addGeometryProperties(self): """Adds geometry properties to this object""" - from nativeifc import ifc_geometry # lazy loading + from . import ifc_geometry # lazy loading ifc_geometry.add_geom_properties(self.Object) def addMaterial(self): """Adds a material to this object""" - from nativeifc import ifc_materials # lazy loading + from . import ifc_materials # lazy loading ifc_materials.show_material(self.Object) self.Object.Document.recompute() @@ -275,8 +275,8 @@ class ifc_vp_object: def showTree(self): """Shows a dialog with a geometry tree for the object""" - from nativeifc import ifc_tools # lazy loading - from nativeifc import ifc_tree # lazy loading + from . import ifc_tools # lazy loading + from . import ifc_tree # lazy loading element = ifc_tools.get_ifc_element(self.Object) if element: @@ -285,7 +285,7 @@ class ifc_vp_object: def showProps(self): """Expands property sets""" - from nativeifc import ifc_psets # lazy loading + from . import ifc_psets # lazy loading ifc_psets.show_psets(self.Object) self.Object.Document.recompute() @@ -313,7 +313,7 @@ class ifc_vp_object: def dragObject(self, vobj, dragged_object): """Remove a child from the view provider by d&d""" - from nativeifc import ifc_tools # lazy import + from . import ifc_tools # lazy import parent = vobj.Object ifc_tools.deaggregate(dragged_object, parent) @@ -329,7 +329,7 @@ class ifc_vp_object: def onDrop(self, incoming_object): """Delayed action to be taken when dropping an object""" - from nativeifc import ifc_tools # lazy import + from . import ifc_tools # lazy import ifc_tools.aggregate(incoming_object, self.Object) if self.hasChildren(self.Object): self.expandChildren(self.Object) @@ -350,7 +350,7 @@ class ifc_vp_object: def createGroup(self): """Creates a group under this object""" - from nativeifc import ifc_tools # lazy import + from . import ifc_tools # lazy import group = self.Object.Document.addObject("App::DocumentObjectGroup", "Group") ifc_tools.aggregate(group, self.Object) @@ -364,13 +364,13 @@ class ifc_vp_object: def expandProperties(self, vobj): """Expands everything that needs to be expanded""" - from nativeifc import ifc_geometry # lazy import - from nativeifc import ifc_tools # lazy import - from nativeifc import ifc_psets # lazy import - from nativeifc import ifc_materials # lazy import - from nativeifc import ifc_layers # lazy import - from nativeifc import ifc_types # lazy import - from nativeifc import ifc_classification # lazy import + from . import ifc_geometry # lazy import + from . import ifc_tools # lazy import + from . import ifc_psets # lazy import + from . import ifc_materials # lazy import + from . import ifc_layers # lazy import + from . import ifc_types # lazy import + from . import ifc_classification # lazy import # generic data loading ifc_geometry.add_geom_properties(vobj.Object) @@ -399,7 +399,7 @@ class ifc_vp_object: if not hasattr(self, "Object"): return - from nativeifc import ifc_types + from . import ifc_types ifc_types.convert_to_type(self.Object) self.Object.Document.recompute() @@ -444,7 +444,7 @@ class ifc_vp_document(ifc_vp_object): def save(self): """Saves the associated IFC file""" - from nativeifc import ifc_tools # lazy import + from . import ifc_tools # lazy import ifc_tools.save(self.Object) self.Object.Document.recompute() @@ -452,7 +452,7 @@ class ifc_vp_document(ifc_vp_object): def saveas(self): """Saves the associated IFC file to another file""" - from nativeifc import ifc_tools # lazy import + from . import ifc_tools # lazy import sf = get_filepath(self.Object) if sf: @@ -503,7 +503,7 @@ class ifc_vp_document(ifc_vp_object): return False def diff(self): - from nativeifc import ifc_diff + from . import ifc_diff diff = ifc_diff.get_diff(self.Object) ifc_diff.show_diff(diff) @@ -600,8 +600,8 @@ class ifc_vp_material: return [] def setupContextMenu(self, vobj, menu): - from nativeifc import ifc_tools # lazy import - from nativeifc import ifc_psets + from . import ifc_tools # lazy import + from . import ifc_psets from PySide import QtCore, QtGui # lazy import if FreeCADGui.activeWorkbench().name() != 'BIMWorkbench': @@ -616,7 +616,7 @@ class ifc_vp_material: def showProps(self): """Expands property sets""" - from nativeifc import ifc_psets # lazy loading + from . import ifc_psets # lazy loading ifc_psets.show_psets(self.Object) self.Object.Document.recompute() @@ -659,7 +659,7 @@ def overlay(icon1, icon2): def get_filepath(project): """Saves the associated IFC file to another file""" - from nativeifc import ifc_tools # lazy import + from . import ifc_tools # lazy import from PySide import QtCore, QtGui # lazy import sf = QtGui.QFileDialog.getSaveFileName(