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
@@ -27,7 +27,7 @@ def add_structural_activity(
ifc_class: str = "IfcStructuralPlanarAction",
predefined_type: str = "CONST",
global_or_local: Literal["GLOBAL_COORDS", "LOCAL_COORDS"] = "GLOBAL_COORDS",
) -> None:
) -> ifcopenshell.entity_instance:
"""Adds a new structural activity
A structural activity is either a structural action or a reaction. It
@@ -38,42 +38,29 @@ def add_structural_activity(
a structural member.
:param ifc_class: Choose from any subtype of IfcStructuralActivity.
:type ifc_class: str
:param predefined_type: View the IFC documentation for what valid
predefined types may be chosen.
:type predefined_type: str
:param global_or_local: The location coordinates of the load is always
defined locally relative to the structural member the activity is
assigned to. However, the directions of the applied load may either
be specified globally or locally depending on how this argument is
set. Choose from GLOBAL_COORDS or LOCAL_COORDS.
:type global_or_local: str
:param applied_load: The IfcStructuralLoad that is applied in this
activity.
:type applied_load: ifcopenshell.entity_instance
:param structural_member: The IfcStructuralMember that the load is
applied to.
:type structural_member: ifcopenshell.entity_instance
:return: The newly created entity based on the ifc_class
:rtype: ifcopenshell.entity_instance
"""
settings = {
"ifc_class": ifc_class,
"predefined_type": predefined_type,
"global_or_local": global_or_local,
"applied_load": applied_load,
"structural_member": structural_member,
}
activity = ifcopenshell.api.root.create_entity(
file,
ifc_class=settings["ifc_class"],
predefined_type=settings["predefined_type"],
ifc_class=ifc_class,
predefined_type=predefined_type,
)
activity.AppliedLoad = settings["applied_load"]
activity.GlobalOrLocal = settings["global_or_local"]
activity.AppliedLoad = applied_load
activity.GlobalOrLocal = global_or_local
rel = ifcopenshell.api.root.create_entity(file, ifc_class="IfcRelConnectsStructuralActivity")
rel.RelatingElement = settings["structural_member"]
rel.RelatingElement = structural_member
rel.RelatedStructuralActivity = activity
return activity
@@ -32,18 +32,14 @@ def add_structural_boundary_condition(
edge condition, and surface connections will have a face condition.
:param name: The name of the boundary condition.
:type name: str,optional
:param connection: The IfcStructuralConnection to apply the boundary
condition to. This will determine the type of condition that is
created. If no connection is supplied, an orphan boundary condition
will be created using the ifc_class that you specify.
:type connection: ifcopenshell.entity_instance,optional
:param ifc_class: The class of IfcBoundaryCondition to create, only
relevant if you do not specify a connection and want to create an
orphaned boundary condition.
:type ifc_class: str,optional
:return: The newly created IfcBoundaryCondition
:rtype: ifcopenshell.entity_instance
Example:
@@ -51,14 +47,12 @@ def add_structural_boundary_condition(
ifcopenshell.api.structural.add_structural_boundary_condition(model, connection=connection)
"""
settings = {"name": name, "connection": connection, "ifc_class": ifc_class}
if settings["connection"]:
if connection:
# assign boundary condition to a connection
if settings["connection"].is_a("IfcRelConnectsStructuralMember"):
related_connection = settings["connection"].RelatedStructuralConnection
if connection.is_a("IfcRelConnectsStructuralMember"):
related_connection = connection.RelatedStructuralConnection
else:
related_connection = settings["connection"]
related_connection = connection
if related_connection.is_a("IfcStructuralPointConnection"):
boundary_class = "IfcBoundaryNodeCondition"
@@ -67,9 +61,9 @@ def add_structural_boundary_condition(
elif related_connection.is_a("IfcStructuralSurfaceConnection"):
boundary_class = "IfcBoundaryFaceCondition"
condition = file.create_entity(boundary_class, Name=settings["name"])
settings["connection"].AppliedCondition = condition
condition = file.create_entity(boundary_class, Name=name)
connection.AppliedCondition = condition
return condition
else:
# add an orphan boundary condition
return file.create_entity(settings["ifc_class"], Name=settings["name"])
return file.create_entity(ifc_class, Name=name)
@@ -29,22 +29,15 @@ def add_structural_member_connection(
:param relating_structural_member: The IfcStructuralMember to have a
connection added to it.
:type relating_structural_member: ifcopenshell.entity_instance
:param related_structural_connection: The IfcStructuralConnection to add
to the IfcStructuralMember.
:type related_structural_connection: ifcopenshell.entity_instance
:return: The IfcRelConnectsStructuralMember relationship
:rtype: ifcopenshell.entity_instance
"""
settings = {
"relating_structural_member": relating_structural_member,
"related_structural_connection": related_structural_connection,
}
for connection in settings["related_structural_connection"].ConnectsStructuralMembers or []:
if connection.RelatingStructuralMember == settings["relating_structural_member"]:
for connection in related_structural_connection.ConnectsStructuralMembers or []:
if connection.RelatingStructuralMember == relating_structural_member:
return connection
rel = ifcopenshell.api.root.create_entity(file, ifc_class="IfcRelConnectsStructuralMember")
rel.RelatingStructuralMember = settings["relating_structural_member"]
rel.RelatedStructuralConnection = settings["related_structural_connection"]
rel.RelatingStructuralMember = relating_structural_member
rel.RelatedStructuralConnection = related_structural_connection
return rel
@@ -27,18 +27,14 @@ def remove_structural_connection_condition(file: ifcopenshell.file, relation: if
The condition and the member itself is preserved.
:param relation: The IfcRelConnectsStructuralMember to remove.
:type relation: ifcopenshell.entity_instance
:return: None
:rtype: None
"""
settings = {"relation": relation}
if settings["relation"].AppliedCondition:
if relation.AppliedCondition:
ifcopenshell.api.structural.remove_structural_boundary_condition(
file,
connection=settings["relation"].RelatedStructuralConnection,
connection=relation.RelatedStructuralConnection,
)
history = settings["relation"].OwnerHistory
file.remove(settings["relation"])
history = relation.OwnerHistory
file.remove(relation)
if history:
ifcopenshell.util.element.remove_deep2(file, history)