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.
This commit is contained in:
vocx-fc
2020-06-28 13:35:19 -05:00
committed by Yorik van Havre
parent d61fa25f43
commit c97d13164e
11 changed files with 35 additions and 24 deletions

View File

@@ -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

View File

@@ -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 = []

View File

@@ -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

View File

@@ -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]

View File

@@ -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

View File

@@ -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:

View File

@@ -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":

View File

@@ -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([])

View File

@@ -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

View File

@@ -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 = []

View File

@@ -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 = []