mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-17 22:11:36 +00:00
Fix bug where psets were unable to be applied for specific predefined types
This commit is contained in:
@@ -63,7 +63,9 @@ class PsetQto:
|
|||||||
if qto_only:
|
if qto_only:
|
||||||
if not prop_set.Name.startswith("Qto_"):
|
if not prop_set.Name.startswith("Qto_"):
|
||||||
continue
|
continue
|
||||||
if any_class or self.is_applicable(entity, prop_set.ApplicableEntity or "IfcRoot", predefined_type):
|
if any_class or self.is_applicable(
|
||||||
|
entity, prop_set.ApplicableEntity or "IfcRoot", predefined_type, prop_set.TemplateType
|
||||||
|
):
|
||||||
result.append(prop_set)
|
result.append(prop_set)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@@ -72,7 +74,9 @@ class PsetQto:
|
|||||||
"""Return names instead of objects for other use eg. enum"""
|
"""Return names instead of objects for other use eg. enum"""
|
||||||
return [prop_set.Name for prop_set in self.get_applicable(ifc_class, predefined_type, pset_only, qto_only)]
|
return [prop_set.Name for prop_set in self.get_applicable(ifc_class, predefined_type, pset_only, qto_only)]
|
||||||
|
|
||||||
def is_applicable(self, entity: entity_instance, applicables: str, predefined_type="") -> bool:
|
def is_applicable(
|
||||||
|
self, entity: entity_instance, applicables: str, predefined_type="", template_type="NOTDEFINED"
|
||||||
|
) -> bool:
|
||||||
"""applicables can have multiple possible patterns :
|
"""applicables can have multiple possible patterns :
|
||||||
IfcBoilerType (IfcClass)
|
IfcBoilerType (IfcClass)
|
||||||
IfcBoilerType/STEAM (IfcClass/PREDEFINEDTYPE)
|
IfcBoilerType/STEAM (IfcClass/PREDEFINEDTYPE)
|
||||||
@@ -85,7 +89,10 @@ class PsetQto:
|
|||||||
continue
|
continue
|
||||||
# Uncomment if usage found
|
# Uncomment if usage found
|
||||||
# applicable_perf_history = match.group(2) or match.group(4)
|
# applicable_perf_history = match.group(2) or match.group(4)
|
||||||
if predefined_type and predefined_type != match.group(3):
|
matched_type = match.group(3)
|
||||||
|
if matched_type and not predefined_type:
|
||||||
|
continue
|
||||||
|
elif matched_type and predefined_type != match.group(3):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
applicable_class = match.group(1)
|
applicable_class = match.group(1)
|
||||||
|
|||||||
@@ -28,8 +28,16 @@ class TestPsetQto:
|
|||||||
|
|
||||||
def test_get_applicables(self):
|
def test_get_applicables(self):
|
||||||
for i in range(1000):
|
for i in range(1000):
|
||||||
assert len(self.pset_qto.get_applicable("IfcMaterial")) == 14
|
assert len(self.pset_qto.get_applicable("IfcMaterial")) == 9
|
||||||
|
|
||||||
def test_get_applicables_names(self):
|
def test_get_applicables_names(self):
|
||||||
for i in range(1000):
|
for i in range(1000):
|
||||||
assert len(self.pset_qto.get_applicable_names("IfcMaterial")) == 14
|
assert len(self.pset_qto.get_applicable_names("IfcMaterial")) == 9
|
||||||
|
|
||||||
|
def test_getting_applicables_for_a_specific_predefined_type(self):
|
||||||
|
names = self.pset_qto.get_applicable_names("IfcAudioVisualAppliance")
|
||||||
|
assert len(names) == 17
|
||||||
|
assert "Pset_AudioVisualApplianceTypeAmplifier" not in names
|
||||||
|
names = self.pset_qto.get_applicable_names("IfcAudioVisualAppliance", predefined_type="AMPLIFIER")
|
||||||
|
assert "Pset_AudioVisualApplianceTypeAmplifier" in names
|
||||||
|
assert len(names) == 18
|
||||||
|
|||||||
Reference in New Issue
Block a user