fix Native IFC Qt6 Support

This commit is contained in:
hoshengwei
2024-05-28 10:17:33 +08:00
committed by Yorik van Havre
parent e64a977398
commit 79ada18d69
3 changed files with 14 additions and 13 deletions

View File

@@ -79,7 +79,7 @@ class ifc_object:
self.rebuild_classlist(obj)
if hasattr(obj, "IfcFilePath"):
# once we have loaded the project, recalculate child coin nodes
from PySide2 import QtCore # lazy loading
from PySide import QtCore # lazy loading
if obj.OutListRecursive:
for child in obj.OutListRecursive:
@@ -167,8 +167,8 @@ class ifc_object:
def edit_geometry(self, obj, prop):
"""Edits a geometry property of an object"""
from nativeifc import ifc_tools # lazy import
from nativeifc import ifc_geometry # lazy loading
from nativeifc import ifc_tools # lazy import
result = ifc_geometry.set_geom_property(obj, prop)
if result:

View File

@@ -24,6 +24,7 @@
import os
import FreeCAD
params = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/NativeIFC")
@@ -38,7 +39,7 @@ def add_observer():
def remove_observer():
"""Removes this observer if present"""
if hasattr(FreeCAD, "BIMobserver"):
FreeCAD.removeDocumentObserver(FreeCAD.BIMobserver)
del FreeCAD.BIMobserver
@@ -56,7 +57,7 @@ class ifc_observer:
def slotStartSaveDocument(self, doc, value):
"""Save all IFC documents in this doc"""
from PySide2 import QtCore # lazy loading
from PySide import QtCore # lazy loading
self.docname = doc.Name
# delay execution to not get caught under the wait sursor
@@ -108,7 +109,7 @@ class ifc_observer:
doc = getattr(obj, "Document", None)
if doc:
if hasattr(doc, "IfcFilePath"):
from PySide2 import QtCore # lazy loading
from PySide import QtCore # lazy loading
self.objname = obj.Name
self.docname = obj.Document.Name
@@ -119,8 +120,8 @@ class ifc_observer:
"""Check if we need to lock"""
from nativeifc import ifc_status
ifc_status.on_activate()
ifc_status.on_activate()
# implementation methods
@@ -156,8 +157,8 @@ class ifc_observer:
ask = params.GetBool("AskBeforeSaving", True)
if ask and FreeCAD.GuiUp:
import FreeCADGui
import Arch_rc
import FreeCADGui
dlg = FreeCADGui.PySideUic.loadUi(":/ui/dialogExport.ui")
result = dlg.exec_()
@@ -193,8 +194,8 @@ class ifc_observer:
del self.objname
if obj.isDerivedFrom("Part::Feature") or "IfcType" in obj.PropertiesList:
FreeCAD.Console.PrintLog("Converting" + obj.Label + "to IFC\n")
from nativeifc import ifc_tools # lazy loading
from nativeifc import ifc_geometry # lazy loading
from nativeifc import ifc_tools # lazy loading
newobj = ifc_tools.aggregate(obj, doc)
ifc_geometry.add_geom_properties(newobj)

View File

@@ -77,10 +77,10 @@ def print_geometry_tree(element):
def show_geometry_tree(element):
"""Same as get_geometry_tree but in a Qt dialog"""
import FreeCADGui # lazy import
from PySide2 import QtGui, QtWidgets
from nativeifc import ifc_tools
import Arch_rc
import FreeCADGui # lazy import
from nativeifc import ifc_tools
from PySide import QtGui, QtWidgets
if isinstance(element, FreeCAD.DocumentObject):
element = ifc_tools.get_ifc_element(element)
@@ -145,9 +145,9 @@ def isfloat(s):
def show_properties(current, previous):
"""Displays object properties"""
from nativeifc import ifc_tools # lazy loading
import FreeCADGui
from PySide2 import QtCore, QtGui, QtWidgets
from nativeifc import ifc_tools # lazy loading
from PySide import QtCore, QtGui, QtWidgets
ifcid = int(current.text(0).split("=", 1)[0].strip(" ").strip("#"))
sel = FreeCADGui.Selection.getSelection()