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
@@ -35,12 +35,9 @@ def add_group(
or structural load groups, which group together loads for structural
analysis, or inventories, which are groups of assets.
:param Name: The name of the group. Defaults to "Unnamed"
:type Name: str, optional
:param name: The name of the group. Defaults to "Unnamed"
:param description: The description of the purpose of the group.
:type description: str, optional
:return: The newly created IfcGroup
:rtype: ifcopenshell.entity_instance
Example:
@@ -48,17 +45,11 @@ def add_group(
ifcopenshell.api.group.add_group(model, name="Unit 1A")
"""
settings = {
"name": name or "Unnamed",
"description": description,
}
return file.create_entity(
"IfcGroup",
**{
"GlobalId": ifcopenshell.guid.new(),
"OwnerHistory": ifcopenshell.api.owner.create_owner_history(file),
"Name": settings["name"],
"Description": settings["description"],
}
GlobalId=ifcopenshell.guid.new(),
OwnerHistory=ifcopenshell.api.owner.create_owner_history(file),
Name=name,
Description=description,
)
@@ -39,9 +39,7 @@ def remove_group(file: ifcopenshell.file, group: ifcopenshell.entity_instance) -
group = ifcopenshell.api.group.add_group(model, name="Unit 1A")
ifcopenshell.api.group.remove_group(model, group=group)
"""
settings = {"group": group}
for inverse_id in [i.id() for i in file.get_inverse(settings["group"])]:
for inverse_id in [i.id() for i in file.get_inverse(group)]:
try:
inverse = file.by_id(inverse_id)
except:
@@ -49,11 +47,11 @@ def remove_group(file: ifcopenshell.file, group: ifcopenshell.entity_instance) -
if inverse.is_a("IfcRelDefinesByProperties"):
ifcopenshell.api.pset.remove_pset(
file,
product=settings["group"],
product=group,
pset=inverse.RelatingPropertyDefinition,
)
elif inverse.is_a("IfcRelAssignsToGroup"):
if inverse.RelatingGroup == settings["group"]:
if inverse.RelatingGroup == group:
history = inverse.OwnerHistory
file.remove(inverse)
if history:
@@ -63,7 +61,7 @@ def remove_group(file: ifcopenshell.file, group: ifcopenshell.entity_instance) -
file.remove(inverse)
if history:
ifcopenshell.util.element.remove_deep2(file, history)
history = settings["group"].OwnerHistory
file.remove(settings["group"])
history = group.OwnerHistory
file.remove(group)
if history:
ifcopenshell.util.element.remove_deep2(file, history)