From 3593946d1c64a82669c79461b63d6438516639ea Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Thu, 2 May 2024 15:26:48 +0200 Subject: [PATCH] BIM: Fixed leftover bugs --- src/Mod/BIM/Arch.py | 5 +++-- src/Mod/BIM/ArchWindowPresets.py | 4 ++-- src/Mod/BIM/bimcommands/BimLeader.py | 3 ++- src/Mod/BIM/bimcommands/BimProfile.py | 4 +++- src/Mod/BIM/bimcommands/BimRoof.py | 1 + src/Mod/BIM/bimcommands/BimSlab.py | 1 + src/Mod/BIM/bimcommands/BimSpace.py | 1 + src/Mod/BIM/bimcommands/BimWall.py | 3 +++ src/Mod/BIM/bimcommands/BimWindow.py | 10 +++++++--- src/Mod/BIM/importers/exportIFC.py | 8 ++++---- src/Mod/BIM/importers/importIFC.py | 6 +++--- src/Mod/BIM/importers/importIFCmulticore.py | 2 +- src/Mod/BIM/nativeifc/ifc_diff.py | 2 +- 13 files changed, 32 insertions(+), 18 deletions(-) diff --git a/src/Mod/BIM/Arch.py b/src/Mod/BIM/Arch.py index d8164803d2..f0f2ff3c51 100644 --- a/src/Mod/BIM/Arch.py +++ b/src/Mod/BIM/Arch.py @@ -44,6 +44,7 @@ translate = FreeCAD.Qt.translate # generic functions from ArchCommands import * +from ArchWindowPresets import * # TODO: migrate this one @@ -122,7 +123,7 @@ def makeFloor(objectslist=None,baseobj=None,name=None): """makes a BuildingPart and turns it into a Floor/Level""" obj = makeBuildingPart(objectslist) - obj.Label = name if name else translate("Arch","Floor") + obj.Label = name if name else translate("Arch","Level") obj.IfcType = "Building Storey" return obj @@ -871,7 +872,7 @@ def makeRailing(stairs): outlineLRAll = stair.OutlineRightAll stairRailingLR = "RailingRight" if outlineLR or outlineLRAll: - lrRail = ArchPipe.makePipe(baseobj=None,diameter=0,length=0,placement=None,name=translate("Arch","Railing")) + lrRail = Arch.makePipe(baseobj=None,diameter=0,length=0,placement=None,name=translate("Arch","Railing")) if outlineLRAll: setattr(stair, stairRailingLR, lrRail) break diff --git a/src/Mod/BIM/ArchWindowPresets.py b/src/Mod/BIM/ArchWindowPresets.py index 4c0577929c..380c2d748d 100644 --- a/src/Mod/BIM/ArchWindowPresets.py +++ b/src/Mod/BIM/ArchWindowPresets.py @@ -501,14 +501,14 @@ def makeWindowPreset(windowtype,width,height,h1,h2,h3,w1,w2,o1,o2,placement=None return (s,wp) if windowtype in WindowPresets: - import ArchWindow + import Arch default = makeSketch(windowtype,width,height,h1,h2,h3,w1,w2,o1,o2) FreeCAD.ActiveDocument.recompute() if default: if placement: default[0].Placement = placement FreeCAD.ActiveDocument.recompute() - obj = ArchWindow.makeWindow(default[0],width,height,default[1]) + obj = Arch.makeWindow(default[0],width,height,default[1]) obj.Preset = WindowPresets.index(windowtype)+1 obj.Frame = w2 obj.Offset = o1 diff --git a/src/Mod/BIM/bimcommands/BimLeader.py b/src/Mod/BIM/bimcommands/BimLeader.py index 434b024015..948034e0e5 100644 --- a/src/Mod/BIM/bimcommands/BimLeader.py +++ b/src/Mod/BIM/bimcommands/BimLeader.py @@ -30,7 +30,7 @@ import FreeCADGui from draftguitools import gui_lines # Line tool from Draft QT_TRANSLATE_NOOP = FreeCAD.Qt.QT_TRANSLATE_NOOP - +translate = FreeCAD.Qt.translate class BIM_Leader(gui_lines.Line): @@ -51,6 +51,7 @@ class BIM_Leader(gui_lines.Line): super(BIM_Leader, self).Activated(name="Leader", icon="Draft_Wire") def finish(self, closed=False, cont=False): + import DraftVecUtils self.removeTemporaryObject() if getattr(self,"oldWP",None): FreeCAD.DraftWorkingPlane = self.oldWP diff --git a/src/Mod/BIM/bimcommands/BimProfile.py b/src/Mod/BIM/bimcommands/BimProfile.py index 6b117f6cdf..27cf3bc011 100644 --- a/src/Mod/BIM/bimcommands/BimProfile.py +++ b/src/Mod/BIM/bimcommands/BimProfile.py @@ -49,9 +49,10 @@ class Arch_Profile: def Activated(self): + import ArchProfile self.Profile = None self.Categories = [] - self.Presets = readPresets() + self.Presets = ArchProfile.readPresets() for pre in self.Presets: if pre[1] not in self.Categories: self.Categories.append(pre[1]) @@ -62,6 +63,7 @@ class Arch_Profile: "sets up a taskbox widget" from PySide import QtGui + from draftutils import params w = QtGui.QWidget() ui = FreeCADGui.UiLoader() w.setWindowTitle(translate("Arch","Profile settings")) diff --git a/src/Mod/BIM/bimcommands/BimRoof.py b/src/Mod/BIM/bimcommands/BimRoof.py index c0a1913a68..f1fceb5617 100644 --- a/src/Mod/BIM/bimcommands/BimRoof.py +++ b/src/Mod/BIM/bimcommands/BimRoof.py @@ -45,6 +45,7 @@ class Arch_Roof: return not FreeCAD.ActiveDocument is None def Activated(self): + import ArchComponent sel = FreeCADGui.Selection.getSelectionEx() if sel: sel = sel[0] diff --git a/src/Mod/BIM/bimcommands/BimSlab.py b/src/Mod/BIM/bimcommands/BimSlab.py index e9e7b37f7d..5d51bd3756 100644 --- a/src/Mod/BIM/bimcommands/BimSlab.py +++ b/src/Mod/BIM/bimcommands/BimSlab.py @@ -28,6 +28,7 @@ import FreeCAD import FreeCADGui QT_TRANSLATE_NOOP = FreeCAD.Qt.QT_TRANSLATE_NOOP +translate = FreeCAD.Qt.translate class BIM_Slab: diff --git a/src/Mod/BIM/bimcommands/BimSpace.py b/src/Mod/BIM/bimcommands/BimSpace.py index 0f6e86e2c3..0097206825 100644 --- a/src/Mod/BIM/bimcommands/BimSpace.py +++ b/src/Mod/BIM/bimcommands/BimSpace.py @@ -49,6 +49,7 @@ class Arch_Space: def Activated(self): + import ArchComponent FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Space")) FreeCADGui.addModule("Arch") sel = FreeCADGui.Selection.getSelection() diff --git a/src/Mod/BIM/bimcommands/BimWall.py b/src/Mod/BIM/bimcommands/BimWall.py index 3c0e9a57ba..f54b0108b3 100644 --- a/src/Mod/BIM/bimcommands/BimWall.py +++ b/src/Mod/BIM/bimcommands/BimWall.py @@ -68,6 +68,7 @@ class Arch_Wall: import Draft import WorkingPlane from draftutils import params + import draftguitools.gui_trackers as DraftTrackers self.Align = ["Center","Left","Right"][params.get_param_arch("WallAlignment")] self.MultiMat = None self.Length = None @@ -199,6 +200,7 @@ class Arch_Wall: created a Part.LineSegment assigned as the variable "trace" """ + from draftutils import params FreeCADGui.addModule("Draft") FreeCADGui.addModule("WorkingPlane") FreeCADGui.doCommand("wp = WorkingPlane.get_working_plane()") @@ -262,6 +264,7 @@ class Arch_Wall: from PySide import QtCore, QtGui import Draft + from draftutils import params w = QtGui.QWidget() ui = FreeCADGui.UiLoader() w.setWindowTitle(translate("Arch","Wall options")) diff --git a/src/Mod/BIM/bimcommands/BimWindow.py b/src/Mod/BIM/bimcommands/BimWindow.py index bb752a9605..108ef439c7 100644 --- a/src/Mod/BIM/bimcommands/BimWindow.py +++ b/src/Mod/BIM/bimcommands/BimWindow.py @@ -153,6 +153,7 @@ class Arch_Window: import Draft self.tracker.finalize() + from ArchWindowPresets import WindowPresets if point is None: return # if something was selected, override the underlying object @@ -252,6 +253,8 @@ class Arch_Window: "sets up a taskbox widget" from draftutils import params + from PySide import QtCore, QtGui, QtSvg + from ArchWindowPresets import WindowPresets w = QtGui.QWidget() ui = FreeCADGui.UiLoader() w.setWindowTitle(translate("Arch","Window options")) @@ -261,14 +264,14 @@ class Arch_Window: include = QtGui.QCheckBox(translate("Arch","Auto include in host object")) include.setChecked(True) grid.addWidget(include,0,0,1,2) - QtCore.QObject.connect(include,QtCore.SIGNAL("stateChanged(int)"),self.setInclude) + include.stateChanged.connect(self.setInclude) # sill height labels = QtGui.QLabel(translate("Arch","Sill height")) values = ui.createWidget("Gui::InputField") grid.addWidget(labels,1,0,1,1) grid.addWidget(values,1,1,1,1) - QtCore.QObject.connect(values,QtCore.SIGNAL("valueChanged(double)"),self.setSill) + values.valueChanged.connect(self.setSill) # check for Parts library and Arch presets @@ -303,7 +306,7 @@ class Arch_Window: valuep.setCurrentIndex(self.Preset) grid.addWidget(labelp,2,0,1,1) grid.addWidget(valuep,2,1,1,1) - QtCore.QObject.connect(valuep,QtCore.SIGNAL("currentIndexChanged(int)"),self.setPreset) + valuep.currentIndexChanged.connect(self.setPreset) for it in self.librarypresets: valuep.addItem(it[0]) @@ -386,6 +389,7 @@ class Arch_Window: def setPreset(self,i): from draftutils import params + from ArchWindowPresets import WindowPresets self.Preset = i if self.doormode: params.set_param_arch("DoorPreset",i) diff --git a/src/Mod/BIM/importers/exportIFC.py b/src/Mod/BIM/importers/exportIFC.py index e168c3bf93..9f51c446f6 100644 --- a/src/Mod/BIM/importers/exportIFC.py +++ b/src/Mod/BIM/importers/exportIFC.py @@ -39,11 +39,11 @@ import Draft import Arch import DraftVecUtils import ArchIFCSchema -import exportIFCHelper -import exportIFCStructuralTools +from importers import exportIFCHelper +from importers import exportIFCStructuralTools from DraftGeomUtils import vec -from importIFCHelper import dd2dms +from importers.importIFCHelper import dd2dms from draftutils import params from draftutils.messages import _msg, _err @@ -2231,7 +2231,7 @@ def getRepresentation( if not joinfacets: shapetype = "triangulated" if usedae: - import importDAE + from importers import importDAE tris = importDAE.triangulate(fcsolid) else: tris = fcsolid.tessellate(tessellation) diff --git a/src/Mod/BIM/importers/importIFC.py b/src/Mod/BIM/importers/importIFC.py index 6b9340243d..adbccf572e 100644 --- a/src/Mod/BIM/importers/importIFC.py +++ b/src/Mod/BIM/importers/importIFC.py @@ -39,8 +39,8 @@ import Draft import Arch import DraftVecUtils import ArchIFCSchema -import importIFCHelper -import importIFCmulticore +from importers import importIFCHelper +from importers import importIFCmulticore from draftutils import params from draftutils.messages import _msg, _err @@ -152,7 +152,7 @@ def export(exportList, filename, colors=None, preferences=None): The export code is now in a separate module; this call is retained in this module for compatibility purposes with older scripts. """ - import exportIFC + from importers import exportIFC exportIFC.export(exportList, filename, colors, preferences) diff --git a/src/Mod/BIM/importers/importIFCmulticore.py b/src/Mod/BIM/importers/importIFCmulticore.py index 619d69f3b8..f54ee00e4d 100644 --- a/src/Mod/BIM/importers/importIFCmulticore.py +++ b/src/Mod/BIM/importers/importIFCmulticore.py @@ -27,7 +27,7 @@ import os import FreeCAD import Draft import Arch -import importIFCHelper +from importers import importIFCHelper from FreeCAD import Base import ArchIFC diff --git a/src/Mod/BIM/nativeifc/ifc_diff.py b/src/Mod/BIM/nativeifc/ifc_diff.py index d54b4a20b4..bb0b078654 100644 --- a/src/Mod/BIM/nativeifc/ifc_diff.py +++ b/src/Mod/BIM/nativeifc/ifc_diff.py @@ -71,7 +71,7 @@ def htmlize(diff): def show_diff(diff): """Shows a dialog showing the diff contents""" - dlg = FreeCADGui.PySideUic.loadUi(":/ui/dialogDiff.ui")) + dlg = FreeCADGui.PySideUic.loadUi(":/ui/dialogDiff.ui") dlg.textEdit.setStyleSheet("background-color: white; color: black;") dlg.textEdit.setHtml(htmlize(diff)) result = dlg.exec_()