mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-09 13:52:23 +00:00
Fix some bugs in IfcTester that prevented tests running on IFC2X3
This commit is contained in:
@@ -130,11 +130,20 @@ class Entity(Facet):
|
|||||||
|
|
||||||
def filter(self, ifc_file, elements):
|
def filter(self, ifc_file, elements):
|
||||||
if isinstance(self.name, str):
|
if isinstance(self.name, str):
|
||||||
results = ifc_file.by_type(self.name, include_subtypes=False)
|
try:
|
||||||
|
results = ifc_file.by_type(self.name, include_subtypes=False)
|
||||||
|
except:
|
||||||
|
# If the user has specified a class that doesn't exist in the version
|
||||||
|
results = []
|
||||||
else:
|
else:
|
||||||
results = []
|
results = []
|
||||||
ifc_classes = [t for t in ifc_file.wrapped_data.types() if t.upper() == self.name]
|
ifc_classes = [t for t in ifc_file.wrapped_data.types() if t.upper() == self.name]
|
||||||
[results.extend(ifc_file.by_type(ifc_class, include_subtypes=False)) for ifc_class in ifc_classes]
|
for ifc_class in ifc_classes:
|
||||||
|
try:
|
||||||
|
results.extend(ifc_file.by_type(ifc_class, include_subtypes=False))
|
||||||
|
except:
|
||||||
|
# If the user has specified a class that doesn't exist in the version
|
||||||
|
continue
|
||||||
if self.predefinedType:
|
if self.predefinedType:
|
||||||
return [r for r in results if self(r)]
|
return [r for r in results if self(r)]
|
||||||
return results
|
return results
|
||||||
@@ -302,7 +311,15 @@ class Classification(Facet):
|
|||||||
|
|
||||||
|
|
||||||
class PartOf(Facet):
|
class PartOf(Facet):
|
||||||
def __init__(self, entity=None, predefinedType=None, relation="IfcRelAggregates", minOccurs=None, maxOccurs=None, instructions=None):
|
def __init__(
|
||||||
|
self,
|
||||||
|
entity=None,
|
||||||
|
predefinedType=None,
|
||||||
|
relation="IfcRelAggregates",
|
||||||
|
minOccurs=None,
|
||||||
|
maxOccurs=None,
|
||||||
|
instructions=None,
|
||||||
|
):
|
||||||
self.parameters = ["entity", "predefinedType", "@relation", "@minOccurs", "@maxOccurs", "@instructions"]
|
self.parameters = ["entity", "predefinedType", "@relation", "@minOccurs", "@maxOccurs", "@instructions"]
|
||||||
self.applicability_templates = [
|
self.applicability_templates = [
|
||||||
"An element with an {relation} relationship with an {entity}",
|
"An element with an {relation} relationship with an {entity}",
|
||||||
@@ -712,23 +729,34 @@ class Material(Facet):
|
|||||||
|
|
||||||
if is_pass and self.value:
|
if is_pass and self.value:
|
||||||
if material.is_a("IfcMaterial"):
|
if material.is_a("IfcMaterial"):
|
||||||
values = {material.Name, getattr(material, "Category")}
|
values = {material.Name, getattr(material, "Category", None)}
|
||||||
elif material.is_a("IfcMaterialList"):
|
elif material.is_a("IfcMaterialList"):
|
||||||
values = set()
|
values = set()
|
||||||
for mat in material.Materials or []:
|
for mat in material.Materials or []:
|
||||||
values.update([mat.Name, getattr(mat, "Category")])
|
values.update([mat.Name, getattr(mat, "Category", None)])
|
||||||
elif material.is_a("IfcMaterialLayerSet"):
|
elif material.is_a("IfcMaterialLayerSet"):
|
||||||
values = {material.LayerSetName}
|
values = {material.LayerSetName}
|
||||||
for item in material.MaterialLayers or []:
|
for item in material.MaterialLayers or []:
|
||||||
values.update([item.Name, item.Category, item.Material.Name, getattr(item.Material, "Category")])
|
values.update(
|
||||||
|
[
|
||||||
|
getattr(item, "Name", None),
|
||||||
|
getattr(item, "Category", None),
|
||||||
|
item.Material.Name,
|
||||||
|
getattr(item.Material, "Category", None),
|
||||||
|
]
|
||||||
|
)
|
||||||
elif material.is_a("IfcMaterialProfileSet"):
|
elif material.is_a("IfcMaterialProfileSet"):
|
||||||
values = {material.Name}
|
values = {material.Name}
|
||||||
for item in material.MaterialProfiles or []:
|
for item in material.MaterialProfiles or []:
|
||||||
values.update([item.Name, item.Category, item.Material.Name, getattr(item.Material, "Category")])
|
values.update(
|
||||||
|
[item.Name, item.Category, item.Material.Name, getattr(item.Material, "Category", None)]
|
||||||
|
)
|
||||||
elif material.is_a("IfcMaterialConstituentSet"):
|
elif material.is_a("IfcMaterialConstituentSet"):
|
||||||
values = {material.Name}
|
values = {material.Name}
|
||||||
for item in material.MaterialConstituents or []:
|
for item in material.MaterialConstituents or []:
|
||||||
values.update([item.Name, item.Category, item.Material.Name, getattr(item.Material, "Category")])
|
values.update(
|
||||||
|
[item.Name, item.Category, item.Material.Name, getattr(item.Material, "Category", None)]
|
||||||
|
)
|
||||||
|
|
||||||
is_pass = False
|
is_pass = False
|
||||||
for value in values:
|
for value in values:
|
||||||
|
|||||||
@@ -297,4 +297,4 @@ class Bcf(Reporter):
|
|||||||
snapshot.write(png)
|
snapshot.write(png)
|
||||||
snapshot.close()
|
snapshot.close()
|
||||||
viewpoint.snapshot = topic.guid+".png"
|
viewpoint.snapshot = topic.guid+".png"
|
||||||
self.bcf.add_viewpoint(topic, viewpoint)
|
self.bcf.add_viewpoint(topic, viewpoint)
|
||||||
|
|||||||
Reference in New Issue
Block a user