From c97d13164ef4ed056b8aa38dc363ee2d26abef6d Mon Sep 17 00:00:00 2001 From: vocx-fc Date: Sun, 28 Jun 2020 13:35:19 -0500 Subject: [PATCH] Arch: update some functions that come from the Draft workbench In particular `getGroupContents` was renamed to `get_group_contents` in the Draft workbench, so the function name is updated accordingly. --- src/Mod/Arch/ArchBuildingPart.py | 12 +++++++----- src/Mod/Arch/ArchCommands.py | 2 +- src/Mod/Arch/ArchFloor.py | 3 ++- src/Mod/Arch/ArchSchedule.py | 2 +- src/Mod/Arch/ArchSectionPlane.py | 9 +++++---- src/Mod/Arch/ArchSpace.py | 3 ++- src/Mod/Arch/exportIFC.py | 16 +++++++++------- src/Mod/Arch/importDAE.py | 3 ++- src/Mod/Arch/importGBXML.py | 3 ++- src/Mod/Arch/importIFClegacy.py | 3 ++- src/Mod/Arch/importOBJ.py | 3 ++- 11 files changed, 35 insertions(+), 24 deletions(-) diff --git a/src/Mod/Arch/ArchBuildingPart.py b/src/Mod/Arch/ArchBuildingPart.py index c62cb98fdb..6c2f42163b 100644 --- a/src/Mod/Arch/ArchBuildingPart.py +++ b/src/Mod/Arch/ArchBuildingPart.py @@ -444,7 +444,7 @@ class BuildingPart(ArchIFC.IfcProduct): "recursively get the shapes of objects inside this BuildingPart" shapes = [] - for child in Draft.getGroupContents(obj): + for child in Draft.get_group_contents(obj): if hasattr(child,'Shape'): shapes.extend(child.Shape.Faces) return shapes @@ -653,7 +653,7 @@ class ViewProviderBuildingPart: "recursively get the colors of objects inside this BuildingPart" colors = [] - for child in Draft.getGroupContents(obj): + for child in Draft.get_group_contents(obj): if hasattr(child,'Shape') and (hasattr(child.ViewObject,"DiffuseColor") or hasattr(child.ViewObject,"ShapeColor")): if hasattr(child.ViewObject,"DiffuseColor") and len(child.ViewObject.DiffuseColor) == len(child.Shape.Faces): colors.extend(child.ViewObject.DiffuseColor) @@ -739,7 +739,8 @@ class ViewProviderBuildingPart: if self.clip: sg.removeChild(self.clip) self.clip = None - for o in Draft.getGroupContents(vobj.Object.Group,walls=True): + for o in Draft.get_group_contents(vobj.Object.Group, + walls=True): if hasattr(o.ViewObject,"Lighting"): o.ViewObject.Lighting = "One side" self.clip = coin.SoClipPlane() @@ -764,7 +765,8 @@ class ViewProviderBuildingPart: if self.clip: sg.removeChild(self.clip) self.clip = None - for o in Draft.getGroupContents(vobj.Object.Group,walls=True): + for o in Draft.get_group_contents(vobj.Object.Group, + walls=True): if hasattr(o.ViewObject,"Lighting"): o.ViewObject.Lighting = "Two side" elif prop == "Visibility": @@ -779,7 +781,7 @@ class ViewProviderBuildingPart: if self.clip: sg.removeChild(self.clip) self.clip = None - for o in Draft.getGroupContents(vobj.Object.Group,walls=True): + for o in Draft.get_group_contents(vobj.Object.Group, walls=True): if hasattr(o.ViewObject,"Lighting"): o.ViewObject.Lighting = "Two side" return True diff --git a/src/Mod/Arch/ArchCommands.py b/src/Mod/Arch/ArchCommands.py index 7c1952173f..bdb87b3494 100644 --- a/src/Mod/Arch/ArchCommands.py +++ b/src/Mod/Arch/ArchCommands.py @@ -692,7 +692,7 @@ def download(url,force=False): def check(objectslist,includehidden=False): """check(objectslist,includehidden=False): checks if the given objects contain only solids""" - objs = Draft.getGroupContents(objectslist) + objs = Draft.get_group_contents(objectslist) if not includehidden: objs = Draft.removeHidden(objs) bad = [] diff --git a/src/Mod/Arch/ArchFloor.py b/src/Mod/Arch/ArchFloor.py index 1fa7a9117c..5ebc04b984 100644 --- a/src/Mod/Arch/ArchFloor.py +++ b/src/Mod/Arch/ArchFloor.py @@ -244,7 +244,8 @@ class _Floor(ArchIFC.IfcProduct): self.Object = obj if (prop == "Group") and hasattr(obj,"Area"): a = 0 - for o in Draft.getObjectsOfType(Draft.getGroupContents(obj.Group,addgroups=True),"Space"): + for o in Draft.getObjectsOfType(Draft.get_group_contents(obj.Group, addgroups=True), + "Space"): if hasattr(o,"Area"): if hasattr(o.Area,"Value"): a += o.Area.Value diff --git a/src/Mod/Arch/ArchSchedule.py b/src/Mod/Arch/ArchSchedule.py index 037e7e96ce..3151ca51fb 100644 --- a/src/Mod/Arch/ArchSchedule.py +++ b/src/Mod/Arch/ArchSchedule.py @@ -200,7 +200,7 @@ class _ArchSchedule: # remove object itself if the object is a group if objs[0].isDerivedFrom("App::DocumentObjectGroup"): objs = objs[0].Group - objs = Draft.getGroupContents(objs) + objs = Draft.get_group_contents(objs) objs = Arch.pruneIncluded(objs,strict=True) # remove the schedule object and its result from the list objs = [o for o in objs if not o == obj] diff --git a/src/Mod/Arch/ArchSectionPlane.py b/src/Mod/Arch/ArchSectionPlane.py index c9fa172fe0..d7ddfa728e 100644 --- a/src/Mod/Arch/ArchSectionPlane.py +++ b/src/Mod/Arch/ArchSectionPlane.py @@ -73,7 +73,7 @@ def makeSectionPlane(objectslist=None,name="Section"): if objectslist: obj.Objects = objectslist bb = FreeCAD.BoundBox() - for o in Draft.getGroupContents(objectslist): + for o in Draft.get_group_contents(objectslist): if hasattr(o,"Shape") and hasattr(o.Shape,"BoundBox"): bb.add(o.Shape.BoundBox) obj.Placement = FreeCAD.DraftWorkingPlane.getPlacement() @@ -132,7 +132,7 @@ def getSectionData(source): p = FreeCAD.Placement(source.Placement) direction = p.Rotation.multVec(FreeCAD.Vector(0,0,1)) if objs: - objs = Draft.getGroupContents(objs,walls=True,addgroups=True) + objs = Draft.get_group_contents(objs, walls=True, addgroups=True) return objs,cutplane,onlySolids,clip,direction @@ -1079,7 +1079,8 @@ class _ViewProviderSectionPlane: if self.clip: sg.removeChild(self.clip) self.clip = None - for o in Draft.getGroupContents(vobj.Object.Objects,walls=True): + for o in Draft.get_group_contents(vobj.Object.Objects, + walls=True): if hasattr(o.ViewObject,"Lighting"): o.ViewObject.Lighting = "One side" self.clip = coin.SoClipPlane() @@ -1376,7 +1377,7 @@ class SectionPlaneTaskPanel: def getBB(self): bb = FreeCAD.BoundBox() if self.obj: - for o in Draft.getGroupContents(self.obj.Objects): + for o in Draft.get_group_contents(self.obj.Objects): if hasattr(o,"Shape") and hasattr(o.Shape,"BoundBox"): bb.add(o.Shape.BoundBox) return bb diff --git a/src/Mod/Arch/ArchSpace.py b/src/Mod/Arch/ArchSpace.py index ae8160e71d..6de3ea2da6 100644 --- a/src/Mod/Arch/ArchSpace.py +++ b/src/Mod/Arch/ArchSpace.py @@ -318,7 +318,8 @@ class _Space(ArchComponent.Component): if hasattr(obj,"EquipmentPower"): if obj.AutoPower: p = 0 - for o in Draft.getObjectsOfType(Draft.getGroupContents(obj.Group,addgroups=True),"Equipment"): + for o in Draft.getObjectsOfType(Draft.get_group_contents(obj.Group, addgroups=True), + "Equipment"): if hasattr(o,"EquipmentPower"): p += o.EquipmentPower if p != obj.EquipmentPower: diff --git a/src/Mod/Arch/exportIFC.py b/src/Mod/Arch/exportIFC.py index c70e8050ad..8be7f275a1 100644 --- a/src/Mod/Arch/exportIFC.py +++ b/src/Mod/Arch/exportIFC.py @@ -210,7 +210,8 @@ def export(exportList,filename,colors=None,preferences=None): ifcfile = ifcopenshell.open(templatefile) ifcfile = exportIFCHelper.writeUnits(ifcfile,preferences["IFC_UNIT"]) history = ifcfile.by_type("IfcOwnerHistory")[0] - objectslist = Draft.getGroupContents(exportList,walls=True,addgroups=True) + objectslist = Draft.get_group_contents(exportList, walls=True, + addgroups=True) annotations = [] for obj in objectslist: if obj.isDerivedFrom("Part::Part2DObject"): @@ -892,9 +893,9 @@ def export(exportList,filename,colors=None,preferences=None): for floor in Draft.getObjectsOfType(objectslist,"Floor")+Draft.getObjectsOfType(objectslist,"BuildingPart"): if (Draft.getType(floor) == "Floor") or (hasattr(floor,"IfcType") and floor.IfcType == "Building Storey"): - objs = Draft.getGroupContents(floor,walls=True,addgroups=True) + objs = Draft.get_group_contents(floor, walls=True, addgroups=True) objs = Arch.pruneIncluded(objs) - objs.remove(floor) # getGroupContents + addgroups will include the floor itself + objs.remove(floor) # get_group_contents + addgroups will include the floor itself buildingelements, spaces = [], [] for c in objs: if c.Name in products and c.Name not in treated: @@ -930,13 +931,14 @@ def export(exportList,filename,colors=None,preferences=None): for building in Draft.getObjectsOfType(objectslist,"Building")+Draft.getObjectsOfType(objectslist,"BuildingPart"): if (Draft.getType(building) == "Building") or (hasattr(building,"IfcType") and building.IfcType == "Building"): - objs = Draft.getGroupContents(building,walls=True,addgroups=True) + objs = Draft.get_group_contents(building, walls=True, + addgroups=True) objs = Arch.pruneIncluded(objs) children = [] childfloors = [] for c in objs: if not (c.Name in treated): - if c.Name != building.Name: # getGroupContents + addgroups will include the building itself + if c.Name != building.Name: # get_group_contents + addgroups will include the building itself if c.Name in products.keys(): if Draft.getType(c) in ["Floor","BuildingPart","Space"]: childfloors.append(products[c.Name]) @@ -970,12 +972,12 @@ def export(exportList,filename,colors=None,preferences=None): # sites for site in exportIFCHelper.getObjectsOfIfcType(objectslist, "Site"): - objs = Draft.getGroupContents(site,walls=True,addgroups=True) + objs = Draft.get_group_contents(site, walls=True, addgroups=True) objs = Arch.pruneIncluded(objs) children = [] childbuildings = [] for c in objs: - if c.Name != site.Name: # getGroupContents + addgroups will include the building itself + if c.Name != site.Name: # get_group_contents + addgroups will include the building itself if c.Name in products.keys(): if not (c.Name in treated): if Draft.getType(c) == "Building": diff --git a/src/Mod/Arch/importDAE.py b/src/Mod/Arch/importDAE.py index b892d48739..a8036fd62d 100644 --- a/src/Mod/Arch/importDAE.py +++ b/src/Mod/Arch/importDAE.py @@ -220,7 +220,8 @@ def export(exportList,filename,tessellation=1,colors=None): defaultmat = None objind = 0 scenenodes = [] - objectslist = Draft.getGroupContents(exportList,walls=True,addgroups=True) + objectslist = Draft.get_group_contents(exportList, walls=True, + addgroups=True) objectslist = Arch.pruneIncluded(objectslist) for obj in objectslist: findex = numpy.array([]) diff --git a/src/Mod/Arch/importGBXML.py b/src/Mod/Arch/importGBXML.py index 0a3ceb8197..86a6a92466 100644 --- a/src/Mod/Arch/importGBXML.py +++ b/src/Mod/Arch/importGBXML.py @@ -85,7 +85,8 @@ def export(objectslist,filename): filestream.write( ' $f\n' % str(building.Area.getValueAs("m^2")) ) # spaces - for space in Draft.getObjectsOfType(Draft.getGroupContents(building.Group,addgroups=True),"Space"): + for space in Draft.getObjectsOfType(Draft.get_group_contents(building.Group, addgroups=True), + "Space"): if not space.Zone: FreeCAD.Console.PrintError(translate("Arch","Error: Space '%s' has no Zone. Aborting.") % space.Label + "\n") return diff --git a/src/Mod/Arch/importIFClegacy.py b/src/Mod/Arch/importIFClegacy.py index aa5fc15785..bd2ed2a1db 100644 --- a/src/Mod/Arch/importIFClegacy.py +++ b/src/Mod/Arch/importIFClegacy.py @@ -971,7 +971,8 @@ def export(exportList,filename): txt = [] # get all children and reorder list to get buildings and floors processed first - objectslist = Draft.getGroupContents(exportList,walls=True,addgroups=True) + objectslist = Draft.get_group_contents(exportList, walls=True, + addgroups=True) objectslist = Arch.pruneIncluded(objectslist) sites = [] diff --git a/src/Mod/Arch/importOBJ.py b/src/Mod/Arch/importOBJ.py index 62443d6ab2..b26074765e 100644 --- a/src/Mod/Arch/importOBJ.py +++ b/src/Mod/Arch/importOBJ.py @@ -162,7 +162,8 @@ def export(exportList,filename,colors=None): outfile.write("# http://www.freecadweb.org\n") offsetv = 1 offsetvn = 1 - objectslist = Draft.getGroupContents(exportList,walls=True,addgroups=True) + objectslist = Draft.get_group_contents(exportList, walls=True, + addgroups=True) objectslist = Arch.pruneIncluded(objectslist) filenamemtl = filename[:-4] + ".mtl" materials = []