Skip to content

Commit

Permalink
Arch: update some functions that come from the Draft workbench
Browse files Browse the repository at this point in the history
In particular `getGroupContents` was renamed to `get_group_contents`
in the Draft workbench, so the function name is updated accordingly.
  • Loading branch information
vocx-fc authored and yorikvanhavre committed Jul 13, 2020
1 parent 6b72865 commit a5aa964
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 24 deletions.
12 changes: 7 additions & 5 deletions src/Mod/Arch/ArchBuildingPart.py
Expand Up @@ -444,7 +444,7 @@ def getShapes(self,obj):
"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
Expand Down Expand Up @@ -653,7 +653,7 @@ def getColors(self,obj):
"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)
Expand Down Expand Up @@ -739,7 +739,8 @@ def onChanged(self,vobj,prop):
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()
Expand All @@ -764,7 +765,8 @@ def onChanged(self,vobj,prop):
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":
Expand All @@ -779,7 +781,7 @@ def onDelete(self,vobj,subelements):
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
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Arch/ArchCommands.py
Expand Up @@ -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 = []
Expand Down
3 changes: 2 additions & 1 deletion src/Mod/Arch/ArchFloor.py
Expand Up @@ -244,7 +244,8 @@ def onChanged(self,obj,prop):
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
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Arch/ArchSchedule.py
Expand Up @@ -200,7 +200,7 @@ def execute(self,obj):
# 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]
Expand Down
9 changes: 5 additions & 4 deletions src/Mod/Arch/ArchSectionPlane.py
Expand Up @@ -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()
Expand Down Expand Up @@ -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


Expand Down Expand Up @@ -1079,7 +1079,8 @@ def onChanged(self,vobj,prop):
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()
Expand Down Expand Up @@ -1376,7 +1377,7 @@ def rotateZ(self):
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
Expand Down
3 changes: 2 additions & 1 deletion src/Mod/Arch/ArchSpace.py
Expand Up @@ -318,7 +318,8 @@ def onChanged(self,obj,prop):
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:
Expand Down
16 changes: 9 additions & 7 deletions src/Mod/Arch/exportIFC.py
Expand Up @@ -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"):
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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])
Expand Down Expand Up @@ -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":
Expand Down
3 changes: 2 additions & 1 deletion src/Mod/Arch/importDAE.py
Expand Up @@ -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([])
Expand Down
3 changes: 2 additions & 1 deletion src/Mod/Arch/importGBXML.py
Expand Up @@ -85,7 +85,8 @@ def export(objectslist,filename):
filestream.write( ' <Area>$f</Area>\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
Expand Down
3 changes: 2 additions & 1 deletion src/Mod/Arch/importIFClegacy.py
Expand Up @@ -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 = []
Expand Down
3 changes: 2 additions & 1 deletion src/Mod/Arch/importOBJ.py
Expand Up @@ -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 = []
Expand Down

0 comments on commit a5aa964

Please sign in to comment.