mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
typing
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user