BIM: cleanup imports in nativeifc

This commit is contained in:
marcuspollio
2025-03-23 23:30:55 +01:00
parent 7bbfa68698
commit 0798d1ca9e
18 changed files with 66 additions and 54 deletions

View File

@@ -22,9 +22,9 @@
"""This module contains IFC-related FreeCAD commands"""
import FreeCAD
import FreeCADGui
from . import ifc_openshell
translate = FreeCAD.Qt.translate
@@ -155,7 +155,7 @@ class IFC_MakeProject:
def Activated(self):
from importers import exportIFC # lazy loading
from . import ifc_tools
from PySide import QtCore, QtGui
from PySide import QtGui
doc = FreeCAD.ActiveDocument
objs = FreeCADGui.Selection.getSelection()

View File

@@ -23,12 +23,15 @@
"""Diffing tool for NativeIFC project objects"""
import difflib
import ifcopenshell
import FreeCAD
import FreeCADGui
import ifcopenshell
from . import ifc_tools
import Arch_rc
from . import ifc_tools
translate = FreeCAD.Qt.translate

View File

@@ -22,9 +22,10 @@
import tempfile
import ifcopenshell
import FreeCAD
import Draft
import ifcopenshell
from importers import exportIFC
from importers import exportIFCHelper

View File

@@ -24,25 +24,24 @@
The only entry point in this module is the generate_geometry() function which is
used by the execute() method of ifc_objects"""
import multiprocessing
import re
import FreeCAD
from FreeCAD import Base
import Part
import ifcopenshell
import ifcopenshell.util.element
import multiprocessing
import FreeCADGui
from pivy import coin
from PySide import QtCore
import FreeCAD
import FreeCADGui
import Part
from FreeCAD import Base
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.
This is the main function called by the execute method of FreeCAD document objects

View File

@@ -22,11 +22,11 @@
"""This module contains geometry editing and geometry properties-related tools"""
import FreeCAD
import ifcopenshell
import ifcopenshell.util.unit
import FreeCAD
from . import ifc_tools

View File

@@ -22,12 +22,12 @@
"""This NativeIFC module deals with layers"""
import ifcopenshell
import ifcopenshell.util.element
from . import ifc_tools
def load_layers(obj):
"""Loads all the layers of an IFC file"""

View File

@@ -22,13 +22,14 @@
"""This NativeIFC module deals with materials"""
import FreeCAD
import ifcopenshell
import ifcopenshell.util.element
import FreeCAD
from . import ifc_tools
def create_material(element, parent, recursive=False):
"""Creates a material object in the given project or parent material"""

View File

@@ -24,12 +24,15 @@
import FreeCAD
import FreeCADGui
translate = FreeCAD.Qt.translate
# the property groups below should not be treated as psets
NON_PSETS = ["Base", "IFC", "", "Geometry", "Dimension", "Linear/radial dimension",
"SectionPlane", "Axis", "PhysicalProperties", "BuildingPart", "IFC Attributes"]
class ifc_object:
"""Base class for all IFC-based objects"""

View File

@@ -22,9 +22,9 @@
"""Document observer to act on documents containing NativeIFC objects"""
import FreeCAD
params = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/NativeIFC")

View File

@@ -24,9 +24,10 @@
"""Utilities to help people verify and update their version of ifcopenshell"""
from packaging.version import Version
import FreeCAD
import FreeCADGui
from packaging.version import Version
from addonmanager_utilities import create_pip_call
translate = FreeCAD.Qt.translate
@@ -139,7 +140,7 @@ class IFC_UpdateIOS:
try:
import ifcopenshell
version = ifcopenshell.version
version = ifcopenshell.version
try:
Version(version)
except InvalidVersion:

View File

@@ -22,8 +22,10 @@
import os
import time
import FreeCAD
import unittest
import FreeCAD
from . import ifc_import

View File

@@ -22,7 +22,6 @@
"""This NativeIFC module deals with properties and property sets"""
import os
import re

View File

@@ -22,13 +22,18 @@
"""Unit test for the Native IFC module"""
import difflib
import os
import time
import tempfile
import FreeCAD
import Draft
import Arch
import unittest
import ifcopenshell
from ifcopenshell.util import element
import FreeCAD
import Arch
import Draft
from . import ifc_import
from . import ifc_tools
from . import ifc_geometry
@@ -37,9 +42,7 @@ 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
IFC_FILE_PATH = None # downloaded IFC file path
FCSTD_FILE_PATH = None # saved FreeCAD file

View File

@@ -23,13 +23,12 @@
"""This contains nativeifc status widgets and functionality"""
import os
import csv
import os
import FreeCAD
import FreeCADGui
translate = FreeCAD.Qt.translate
params = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/NativeIFC")
text_on = translate("BIM", "Strict IFC mode is ON (all objects are IFC)")
@@ -100,7 +99,7 @@ def on_add_property():
sel = FreeCADGui.Selection.getSelection()
if not sel:
return
from PySide import QtCore, QtGui # lazy loading
from PySide import QtGui # lazy loading
from . import ifc_psets
obj = sel[0]
psets = list(set([obj.getGroupOfProperty(p) for p in obj.PropertiesList]))
@@ -179,7 +178,6 @@ def on_add_pset():
sel = FreeCADGui.Selection.getSelection()
if not sel:
return
from PySide import QtCore, QtGui # lazy loading
from . import ifc_psets
obj = sel[0]
mw = FreeCADGui.getMainWindow()
@@ -273,7 +271,7 @@ def on_new():
def set_menu(locked=False):
"""Sets the File menu items"""
from PySide import QtCore, QtGui # lazy loading
from PySide import QtGui # lazy loading
# switch Std_Save and IFC_Save
mw = FreeCADGui.getMainWindow()
@@ -452,7 +450,6 @@ def lock_document():
def find_toplevel(objs):
"""Finds the top-level objects from the list"""
import Draft
# filter out any object that depend on another from the list
nobjs = []
for obj in objs:
@@ -474,6 +471,8 @@ def find_toplevel(objs):
def filter_out(objs):
"""Filter out objects that should not be converted to IFC"""
import Draft
nobjs = []
for obj in objs:
if obj.isDerivedFrom("Part::Feature"):

View File

@@ -23,9 +23,15 @@
"""This is the main NativeIFC module"""
import os
from PySide import QtCore
import FreeCAD
import Draft
import Arch
import ArchBuildingPart
import Draft
from draftviewproviders import view_layer
translate = FreeCAD.Qt.translate
@@ -59,10 +65,6 @@ from . import ifc_status
from . import ifc_export
from . import ifc_psets
from draftviewproviders import view_layer
import ArchBuildingPart
from PySide import QtCore
SCALE = 1000.0 # IfcOpenShell works in meters, FreeCAD works in mm
SHORT = False # If True, only Step ID attribute is created
ROUND = 8 # rounding value for placements

View File

@@ -22,7 +22,6 @@
"""This NativeIFC module handles the retrieval and display of geometry compositions of objects"""
import FreeCAD
TAB = 2
@@ -80,7 +79,7 @@ def show_geometry_tree(element):
import Arch_rc
import FreeCADGui # lazy import
from . import ifc_tools
from PySide import QtGui, QtWidgets
from PySide import QtWidgets
if isinstance(element, FreeCAD.DocumentObject):
element = ifc_tools.get_ifc_element(element)
@@ -147,7 +146,7 @@ def show_properties(current, previous):
import FreeCADGui
from . import ifc_tools # lazy loading
from PySide import QtCore, QtGui, QtWidgets
from PySide import QtCore, QtWidgets
ifcid = int(current.text(0).split("=", 1)[0].strip(" ").strip("#"))
sel = FreeCADGui.Selection.getSelection()

View File

@@ -22,8 +22,8 @@
"""Diffing tool for NativeIFC project objects"""
import FreeCAD
from . import ifc_tools
translate = FreeCAD.Qt.translate

View File

@@ -86,7 +86,7 @@ class ifc_vp_object:
from . import ifc_psets
from . import ifc_materials
from . import ifc_types
from PySide import QtCore, QtGui # lazy import
from PySide import QtGui # lazy import
if FreeCADGui.activeWorkbench().name() != 'BIMWorkbench':
return
@@ -419,7 +419,7 @@ class ifc_vp_document(ifc_vp_object):
def setupContextMenu(self, vobj, menu):
from PySide import QtCore, QtGui # lazy import
from PySide import QtGui # lazy import
if FreeCADGui.activeWorkbench().name() != 'BIMWorkbench':
return
@@ -463,7 +463,7 @@ class ifc_vp_document(ifc_vp_object):
def replace_file(self, obj, newfile):
"""Asks the user if the attached file path needs to be replaced"""
from PySide import QtCore, QtGui # lazy import
from PySide import QtGui # lazy import
msg = "Replace the stored IFC file path in object "
msg += self.Object.Label + " with the new one: "
@@ -484,7 +484,7 @@ class ifc_vp_document(ifc_vp_object):
return False
def schema_warning(self):
from PySide import QtCore, QtGui # lazy import
from PySide import QtGui # lazy import
msg = "Warning: This operation will change the whole IFC file contents "
msg += "and will not give versionable results. It is best to not do "
@@ -516,7 +516,7 @@ class ifc_vp_group:
self.Object = vobj.Object
def getIcon(self):
from PySide import QtCore, QtGui # lazy loading
from PySide import QtGui # lazy loading
import Draft_rc
import Arch_rc
@@ -602,7 +602,7 @@ class ifc_vp_material:
def setupContextMenu(self, vobj, menu):
from . import ifc_tools # lazy import
from . import ifc_psets
from PySide import QtCore, QtGui # lazy import
from PySide import QtGui # lazy import
if FreeCADGui.activeWorkbench().name() != 'BIMWorkbench':
return
@@ -660,7 +660,7 @@ def get_filepath(project):
"""Saves the associated IFC file to another file"""
from . import ifc_tools # lazy import
from PySide import QtCore, QtGui # lazy import
from PySide import QtGui # lazy import
sf = QtGui.QFileDialog.getSaveFileName(
None,