This commit is contained in:
Andrej730
2025-03-14 10:43:47 +05:00
parent 10ecac33b8
commit 0e8810c1f5
118 changed files with 869 additions and 1203 deletions
@@ -71,19 +71,15 @@ def add_pset_template(
overridden by occurrences, and is applicable to everything.
:param name: The name of the property set
:type name: str,optional
:param template_type: Choose from one of PSET_TYPEDRIVENONLY,
PSET_TYPEDRIVENOVERRIDE, PSET_OCCURRENCEDRIVEN,
PSET_PERFORMANCEDRIVEN, QTO_TYPEDRIVENONLY, QTO_TYPEDRIVENOVERRIDE,
QTO_OCCURRENCEDRIVEN, NOTDEFINED
:type template_type: str,optional
:param applicable_entity: The entity that this template is allowed to be
applied to. For example, IfcWall means that the property set may be
assigned to walls only. IfcTypeObject, the default, means that the
property set may be assigned to any type.
:type applicable_entity: str,optional
:return: The newly created IfcPropertySetTemplate
:rtype: ifcopenshell.entity_instance
Example:
@@ -99,12 +95,10 @@ def add_pset_template(
name="HighVoltage", description="Whether there is a risk of high voltage.",
primary_measure_type="IfcBoolean")
"""
settings = {"name": name, "template_type": template_type, "applicable_entity": applicable_entity}
return file.create_entity(
"IfcPropertySetTemplate",
GlobalId=ifcopenshell.guid.new(),
Name=settings["name"],
TemplateType=settings["template_type"],
ApplicableEntity=settings["applicable_entity"],
Name=name,
TemplateType=template_type,
ApplicableEntity=applicable_entity,
)
@@ -27,9 +27,7 @@ def remove_prop_template(file: ifcopenshell.file, prop_template: ifcopenshell.en
templates.
:param prop_template: The IfcSimplePropertyTemplate to remove.
:type prop_template: ifcopenshell.entity_instance
:return: None
:rtype: None
Example:
@@ -44,13 +42,11 @@ def remove_prop_template(file: ifcopenshell.file, prop_template: ifcopenshell.en
# Let's remove the second one.
ifcopenshell.api.pset_template.remove_prop_template(model, prop_template=prop2)
"""
settings = {"prop_template": prop_template}
for inverse in file.get_inverse(settings["prop_template"]):
for inverse in file.get_inverse(prop_template):
if len(inverse.HasPropertyTemplates) == 1:
inverse.HasPropertyTemplates = []
else:
has_property_templates = list(inverse.HasPropertyTemplates)
has_property_templates.remove(settings["prop_template"])
has_property_templates.remove(prop_template)
inverse.HasPropertyTemplates = has_property_templates
ifcopenshell.util.element.remove_deep(file, settings["prop_template"])
ifcopenshell.util.element.remove_deep(file, prop_template)
@@ -26,9 +26,7 @@ def remove_pset_template(file: ifcopenshell.file, pset_template: ifcopenshell.en
along with it.
:param pset_template: The IfcPropertySetTemplate to remove.
:type pset_template: ifcopenshell.entity_instance
:return: None
:rtype: None
Example:
@@ -40,6 +38,4 @@ def remove_pset_template(file: ifcopenshell.file, pset_template: ifcopenshell.en
# Let's remove the template.
ifcopenshell.api.pset_template.remove_pset_template(model, pset_template=template)
"""
settings = {"pset_template": pset_template}
ifcopenshell.util.element.remove_deep(file, settings["pset_template"])
ifcopenshell.util.element.remove_deep(file, pset_template)