From 67f1b41bc21627835026e82abd6c4dce29ead123 Mon Sep 17 00:00:00 2001 From: marcuspollio <131592747+marcuspollio@users.noreply.github.com> Date: Mon, 12 May 2025 17:40:12 +0200 Subject: [PATCH] BIM: fix some imports and cleanup miscellaneous (#20914) --- src/Mod/BIM/ArchBuildingPart.py | 3 +- src/Mod/BIM/OfflineRenderingUtils.py | 2 +- src/Mod/BIM/bimcommands/BimDiff.py | 1 + src/Mod/BIM/bimcommands/BimEquipment.py | 56 +------------------------ src/Mod/BIM/bimcommands/BimLibrary.py | 40 +----------------- src/Mod/BIM/bimcommands/BimUnclone.py | 1 + 6 files changed, 7 insertions(+), 96 deletions(-) diff --git a/src/Mod/BIM/ArchBuildingPart.py b/src/Mod/BIM/ArchBuildingPart.py index c2f20b7695..48b24dd7c8 100644 --- a/src/Mod/BIM/ArchBuildingPart.py +++ b/src/Mod/BIM/ArchBuildingPart.py @@ -37,6 +37,7 @@ import os import tempfile import FreeCAD +import Arch import ArchCommands import ArchIFC import Draft @@ -938,7 +939,7 @@ class ViewProviderBuildingPart: no = Draft.clone(o) Draft.move(no,FreeCAD.Vector(0,0,height)) ng.append(no) - nobj = makeBuildingPart() + nobj = Arch.makeBuildingPart() Draft.formatObject(nobj,self.Object) nobj.Placement = self.Object.Placement nobj.Placement.move(FreeCAD.Vector(0,0,height)) diff --git a/src/Mod/BIM/OfflineRenderingUtils.py b/src/Mod/BIM/OfflineRenderingUtils.py index 18d6553834..5e1b866f6f 100755 --- a/src/Mod/BIM/OfflineRenderingUtils.py +++ b/src/Mod/BIM/OfflineRenderingUtils.py @@ -909,7 +909,7 @@ def saveiv(scene,filename): wa=coin.SoWriteAction() wa.getOutput().openFile(filename) wa.getOutput().setBinary(False) - wa.apply(sc) + wa.apply(scene) wa.getOutput().closeFile() diff --git a/src/Mod/BIM/bimcommands/BimDiff.py b/src/Mod/BIM/bimcommands/BimDiff.py index 3a8cffceca..dad3b7620c 100644 --- a/src/Mod/BIM/bimcommands/BimDiff.py +++ b/src/Mod/BIM/bimcommands/BimDiff.py @@ -52,6 +52,7 @@ class BIM_Diff: # what will be compared: IDs, geometry, materials. Everything else is discarded. from PySide import QtGui import Draft + import Part MOVE_TOLERANCE = 0.2 # the max allowed move in mm VOL_TOLERANCE = 250 # the max allowed volume diff in mm^3 diff --git a/src/Mod/BIM/bimcommands/BimEquipment.py b/src/Mod/BIM/bimcommands/BimEquipment.py index bb60b86b05..7abc5aa1e1 100644 --- a/src/Mod/BIM/bimcommands/BimEquipment.py +++ b/src/Mod/BIM/bimcommands/BimEquipment.py @@ -91,58 +91,4 @@ class Arch_Equipment: return -class Arch_3Views: - - # OBSOLETE - - "the Arch 3Views command definition" - - def GetResources(self): - - return {'Pixmap' : 'Arch_3Views', - 'MenuText': QT_TRANSLATE_NOOP("Arch_3Views","3 views from mesh"), - 'ToolTip': QT_TRANSLATE_NOOP("Arch_3Views","Creates 3 views (top, front, side) from a mesh-based object")} - - def IsActive(self): - - return not FreeCAD.ActiveDocument is None - - def Activated(self): - - s = FreeCADGui.Selection.getSelection() - if len(s) != 1: - FreeCAD.Console.PrintError(translate("Arch","You must select exactly one base object")) - else: - obj = s[0] - if not obj.isDerivedFrom("Mesh::Feature"): - FreeCAD.Console.PrintError(translate("Arch","The selected object must be a mesh")) - else: - if obj.Mesh.CountFacets > 1000: - msgBox = QtGui.QMessageBox() - msgBox.setText(translate("Arch","This mesh has more than 1000 facets.")) - msgBox.setInformativeText(translate("Arch","This operation can take a long time. Proceed?")) - msgBox.setStandardButtons(QtGui.QMessageBox.Ok | QtGui.QMessageBox.Cancel) - msgBox.setDefaultButton(QtGui.QMessageBox.Cancel) - ret = msgBox.exec_() - if ret == QtGui.QMessageBox.Cancel: - return - elif obj.Mesh.CountFacets >= 500: - FreeCAD.Console.PrintWarning(translate("Arch","The mesh has more than 500 facets. This will take a couple of minutes...")) - FreeCAD.ActiveDocument.openTransaction(str(translate("Arch","Create 3 views"))) - FreeCADGui.addModule("Arch") - FreeCADGui.addModule("Part") - FreeCADGui.doCommand("s1 = Arch.createMeshView(FreeCAD.ActiveDocument." + obj.Name + ",FreeCAD.Vector(0,0,-1),outeronly=False,largestonly=False)") - FreeCADGui.doCommand("Part.show(s1)") - FreeCADGui.doCommand("s2 = Arch.createMeshView(FreeCAD.ActiveDocument." + obj.Name + ",FreeCAD.Vector(1,0,0),outeronly=False,largestonly=False)") - FreeCADGui.doCommand("Part.show(s2)") - FreeCADGui.doCommand("s3 = Arch.createMeshView(FreeCAD.ActiveDocument." + obj.Name + ",FreeCAD.Vector(0,1,0),outeronly=False,largestonly=False)") - FreeCADGui.doCommand("Part.show(s3)") - FreeCAD.ActiveDocument.commitTransaction() - FreeCAD.ActiveDocument.recompute() - return - - - - -FreeCADGui.addCommand('Arch_Equipment',Arch_Equipment()) -#FreeCADGui.addCommand('Arch_3Views', Arch_3Views()) +FreeCADGui.addCommand('Arch_Equipment',Arch_Equipment()) \ No newline at end of file diff --git a/src/Mod/BIM/bimcommands/BimLibrary.py b/src/Mod/BIM/bimcommands/BimLibrary.py index de6f2f9f25..3fe049503d 100644 --- a/src/Mod/BIM/bimcommands/BimLibrary.py +++ b/src/Mod/BIM/bimcommands/BimLibrary.py @@ -28,6 +28,7 @@ from __future__ import print_function import os import sys +import tempfile import FreeCAD import FreeCADGui @@ -776,43 +777,6 @@ class BIM_Library_TaskPanel: ) ) - def getOnlineContentsWEB(self, url): - """Returns a dirs,files pair representing files found from a github url. OBSOLETE""" - - # obsolete code - now using getOnlineContentsAPI - import urllib.request - result = {} - u = urllib.request.urlopen(url) - if u: - p = u.read() - if sys.version_info.major >= 3: - p = str(p) - dirs = re.findall(r"<.*?octicon-file-directory.*?href.*?>(.*?)", p) - files = re.findall(r'<.*?octicon-file".*?href.*?>(.*?)', p) - nfiles = [] - for f in files: - for ft in self.getFilters(): - if f.endswith(ft[1:]): - nfiles.append(f) - break - files = nfiles - for d in dirs: - # - if "(.*?)<", d) - d2 = re.findall(r"(.*?)$", d) - if d1 and d2: - d = d1[0] + "/" + d2[0] - r = self.getOnlineContentsWEB(url + "/" + d.replace(" ", "%20")) - result[d] = r - for f in files: - result[f] = f - else: - FreeCAD.Console.PrintError( - translate("BIM", "Cannot open URL") + ":" + url + "\n" - ) - return result - def getOnlineContentsAPI(self, url): """same as getOnlineContents but uses github API (faster)""" @@ -906,8 +870,6 @@ class BIM_Library_TaskPanel: def writeOfflineLib(): if USE_API: rootfiles = self.getOnlineContentsAPI(LIBRARYURL) - else: - rootfiles = self.getOnlineContentsWEB(LIBRARYURL) if rootfiles: templibfile = os.path.join(TEMPLIBPATH, LIBINDEXFILE) os.makedirs(TEMPLIBPATH, exist_ok=True) diff --git a/src/Mod/BIM/bimcommands/BimUnclone.py b/src/Mod/BIM/bimcommands/BimUnclone.py index dfc20bf9ed..29cabdc532 100644 --- a/src/Mod/BIM/bimcommands/BimUnclone.py +++ b/src/Mod/BIM/bimcommands/BimUnclone.py @@ -48,6 +48,7 @@ class BIM_Unclone: return v def Activated(self): + import Arch import Draft # get selected object and face