mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 09:48:32 +00:00
searching for an IfcMaterial in IfcMaterialDefinitions (#2503)
* searching for an IfcMaterial in IfcMaterialDefinitions A start to trying to address: https://community.osarch.org/discussion/comment/13024/#Comment_13024 * refactored to a tighter version. Thanks Thomas.
This commit is contained in:
@@ -188,7 +188,7 @@ class Selector:
|
||||
elif token_type == "NULL":
|
||||
value = None
|
||||
for element in elements:
|
||||
element_value = cls.get_element_value(element, key)
|
||||
element_value = cls.get_element_value(element, key, value)
|
||||
if element_value is None and value is not None and "not" not in comparison:
|
||||
continue
|
||||
if comparison and cls.filter_element(element, element_value, comparison, value):
|
||||
@@ -198,7 +198,7 @@ class Selector:
|
||||
return results
|
||||
|
||||
@classmethod
|
||||
def get_element_value(cls, element, key):
|
||||
def get_element_value(cls, element, key, value):
|
||||
if "." in key and key.split(".")[0] == "type":
|
||||
try:
|
||||
element = ifcopenshell.util.element.get_type(element)
|
||||
@@ -209,12 +209,17 @@ class Selector:
|
||||
key = ".".join(key.split(".")[1:])
|
||||
elif "." in key and key.split(".")[0] == "material":
|
||||
try:
|
||||
element = ifcopenshell.util.element.get_material(element, should_skip_usage=True)
|
||||
if not element:
|
||||
material_definition = ifcopenshell.util.element.get_material(element, should_skip_usage=True)
|
||||
key = ".".join(key.split(".")[1:])
|
||||
materials = [inst for inst in cls.file.traverse(material_definition) if inst.is_a('IfcMaterial')]
|
||||
for material in materials:
|
||||
info = material.get_info()
|
||||
if key in info and info[key] == value:
|
||||
element = material
|
||||
if not material_definition:
|
||||
return None
|
||||
except:
|
||||
return
|
||||
key = ".".join(key.split(".")[1:])
|
||||
elif "." in key and key.split(".")[0] == "container":
|
||||
try:
|
||||
element = ifcopenshell.util.element.get_container(element)
|
||||
|
||||
Reference in New Issue
Block a user