BIM: IFC explorer Qt 6 compatibility and other fixes (#17649)
* BIM: IFC - Fixes for Qt 6 due to QtGui.QFont.setWeight() PySide6 replaced: PySide6.QtGui.QFont.setWeight(int) with: PySide6.QtGui.QFont.setWeight(PySide6.QtGui.QFont.Weight) * BIM: Fix IFC explorer addEntity() and addProperties() on Qt 6 Qt 6 removed QTreeWidget.setFirstItemColumnSpanned() https://doc.qt.io/qt-5/qtreewidget-obsolete.html#setFirstItemColumnSpanned Running the Python command 'BIM_IfcExplorer' failed: Traceback (most recent call last): File "/usr/lib64/freecad/Mod/BIM/bimcommands/BimIfcExplorer.py", line 170, in Activated self.open() File "/usr/lib64/freecad/Mod/BIM/bimcommands/BimIfcExplorer.py", line 223, in open self.addEntity(eid, children, self.tree) File "/usr/lib64/freecad/Mod/BIM/bimcommands/BimIfcExplorer.py", line 455, in addEntity self.tree.setFirstItemColumnSpanned(item, True) * BIM: Fix IFC explorer exception on toggle mesh Traceback (most recent call last): File "/usr/lib64/freecad/Mod/BIM/bimcommands/BimIfcExplorer.py", line 278, in toggleMesh import importIFCHelper ModuleNotFoundError: No module named 'importIFCHelper' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/lib64/freecad/Mod/BIM/bimcommands/BimIfcExplorer.py", line 282, in toggleMesh import importIFC ModuleNotFoundError: No module named 'importIFC' * BIM: Fix IFC explorer layout warnings QLayout: Attempting to add QLayout "" to QDialog "IfcExplorer", which already has a layout QLayout: Attempting to add QLayout "" to QDialog "IfcExplorer", which already has a layout https://doc.qt.io/qt-6/qtwidgets-tutorials-widgets-nestedlayouts-example.html * BIM: Output an error if IFC explorer can't explore a file --------- Co-authored-by: Roy-043 <info@b-k-g.nl>
This commit is contained in:
@@ -60,7 +60,6 @@ class BIM_IfcExplorer:
|
||||
|
||||
# setting up a font
|
||||
self.bold = QtGui.QFont()
|
||||
self.bold.setWeight(75)
|
||||
self.bold.setBold(True)
|
||||
|
||||
# setting up a link fint
|
||||
@@ -108,15 +107,16 @@ class BIM_IfcExplorer:
|
||||
self.dialog.resize(720, 540)
|
||||
toolbar = FreeCADGui.UiLoader().createWidget("Gui::ToolBar")
|
||||
|
||||
layout = QtGui.QVBoxLayout(self.dialog)
|
||||
layout = QtGui.QVBoxLayout()
|
||||
layout.addWidget(toolbar)
|
||||
hlayout = QtGui.QHBoxLayout(self.dialog)
|
||||
hlayout = QtGui.QHBoxLayout()
|
||||
hlayout.addWidget(self.tree)
|
||||
layout.addLayout(hlayout)
|
||||
vlayout = QtGui.QVBoxLayout(self.dialog)
|
||||
vlayout = QtGui.QVBoxLayout()
|
||||
hlayout.addLayout(vlayout)
|
||||
vlayout.addWidget(self.attributes)
|
||||
vlayout.addWidget(self.properties)
|
||||
self.dialog.setLayout(layout)
|
||||
|
||||
# draw the toolbar buttons
|
||||
self.openAction = QtGui.QAction(translate("BIM", "Open"), None)
|
||||
@@ -217,6 +217,17 @@ class BIM_IfcExplorer:
|
||||
self.ifc = ifcopenshell.open(self.filename)
|
||||
root = self.getEntitiesTree()
|
||||
|
||||
# unable to find IfcSite
|
||||
if not root:
|
||||
FreeCAD.Console.PrintError(
|
||||
translate(
|
||||
"BIM",
|
||||
"IfcSite element was not found in %s. Unable to explore.",
|
||||
)
|
||||
% self.filename + "\n"
|
||||
)
|
||||
return
|
||||
|
||||
# populate tree contents
|
||||
for eid, children in root.items():
|
||||
self.addEntity(eid, children, self.tree)
|
||||
@@ -274,11 +285,11 @@ class BIM_IfcExplorer:
|
||||
self.mesh.ViewObject.show()
|
||||
else:
|
||||
try:
|
||||
import importIFCHelper
|
||||
from importers import importIFCHelper
|
||||
|
||||
s = importIFCHelper.getScaling(self.ifc)
|
||||
except:
|
||||
import importIFC
|
||||
from importers import importIFC
|
||||
|
||||
s = importIFC.getScaling(self.ifc)
|
||||
s *= 1000 # ifcopenshell outputs its meshes in metres
|
||||
@@ -451,7 +462,7 @@ class BIM_IfcExplorer:
|
||||
item.setIcon(0, QtGui.QIcon(":icons/Arch_Rebar.svg"))
|
||||
elif entity.is_a("IfcProduct"):
|
||||
item.setIcon(0, QtGui.QIcon(":icons/Arch_Component.svg"))
|
||||
self.tree.setFirstItemColumnSpanned(item, True)
|
||||
item.setFirstColumnSpanned(True)
|
||||
item.setData(0, QtCore.Qt.UserRole, eid)
|
||||
for childid, grandchildren in children.items():
|
||||
self.addEntity(childid, grandchildren, item)
|
||||
@@ -558,7 +569,7 @@ class BIM_IfcExplorer:
|
||||
+ self.tostr(rel.RelatingPropertyDefinition.Name),
|
||||
)
|
||||
item.setFont(0, self.bold)
|
||||
self.properties.setFirstItemColumnSpanned(item, True)
|
||||
item.setFirstColumnSpanned(True)
|
||||
if hasattr(rel.RelatingPropertyDefinition, "HasProperties"):
|
||||
for prop in rel.RelatingPropertyDefinition.HasProperties:
|
||||
subitem = QtGui.QTreeWidgetItem(item)
|
||||
|
||||
@@ -1793,7 +1793,6 @@ def explorer(filename,schema="IFC2X3_TC1.exp"):
|
||||
tree.headerItem().setText(1, "")
|
||||
tree.headerItem().setText(2, "Item and Properties")
|
||||
bold = QtGui.QFont()
|
||||
bold.setWeight(75)
|
||||
bold.setBold(True)
|
||||
|
||||
#print(ifc.Entities)
|
||||
|
||||
Reference in New Issue
Block a user