This commit is contained in:
Andrej730
2024-05-10 11:21:53 +05:00
parent e7eb00eaa3
commit c50d1ea2fe
105 changed files with 502 additions and 251 deletions
@@ -17,15 +17,16 @@
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import ifcopenshell.api
from typing import Literal
def add_structural_activity(
file,
ifc_class="IfcStructuralPlanarAction",
predefined_type="CONST",
global_or_local="GLOBAL_COORDS",
applied_load=None,
structural_member=None,
file: ifcopenshell.file,
applied_load: ifcopenshell.entity_instance,
structural_member: ifcopenshell.entity_instance,
ifc_class: str = "IfcStructuralPlanarAction",
predefined_type: str = "CONST",
global_or_local: Literal["GLOBAL_COORDS", "LOCAL_COORDS"] = "GLOBAL_COORDS",
) -> None:
"""Adds a new structural activity
@@ -20,7 +20,7 @@ import ifcopenshell
import ifcopenshell.api
def add_structural_analysis_model(file) -> None:
def add_structural_analysis_model(file: ifcopenshell.file) -> ifcopenshell.entity_instance:
"""Add a new structural analysis model
A structural analysis model is a group of all the loads, reactions,
@@ -39,8 +39,6 @@ def add_structural_analysis_model(file) -> None:
# Create a fresh blank structural analysis
analysis = ifcopenshell.api.run("structural.add_structural_analysis_model", model)
"""
settings = {}
return ifcopenshell.api.run(
"root.create_entity", file, ifc_class="IfcStructuralAnalysisModel", predefined_type="LOADING_3D"
)
@@ -15,9 +15,16 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import ifcopenshell
from typing import Optional
def add_structural_boundary_condition(file, name=None, connection=None, ifc_class="IfcBoundaryNodeCondition") -> None:
def add_structural_boundary_condition(
file: ifcopenshell.file,
name: Optional[str] = None,
connection: Optional[ifcopenshell.entity_instance] = None,
ifc_class: str = "IfcBoundaryNodeCondition",
) -> ifcopenshell.entity_instance:
"""Adds a new structural boundary condition to a structural connection
The type of boundary condition depends on the connection. Point
@@ -60,7 +67,9 @@ def add_structural_boundary_condition(file, name=None, connection=None, ifc_clas
elif related_connection.is_a("IfcStructuralSurfaceConnection"):
boundary_class = "IfcBoundaryFaceCondition"
settings["connection"].AppliedCondition = file.create_entity(boundary_class, Name=settings["name"])
condition = file.create_entity(boundary_class, Name=settings["name"])
settings["connection"].AppliedCondition = condition
return condition
else:
# add an orphan boundary condition
return file.create_entity(settings["ifc_class"], Name=settings["name"])
@@ -17,9 +17,12 @@
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import ifcopenshell.api
from typing import Optional
def add_structural_load(file, name=None, ifc_class="IfcStructuralLoadLinearForce") -> None:
def add_structural_load(
file: ifcopenshell.file, name: Optional[str] = None, ifc_class: str = "IfcStructuralLoadLinearForce"
) -> ifcopenshell.entity_instance:
"""Adds a new structural load
Structural loads may be actions or reactions. A simple load might be a
@@ -42,9 +45,4 @@ def add_structural_load(file, name=None, ifc_class="IfcStructuralLoadLinearForce
# Create a simple linear load
ifcopenshell.api.run("structural.add_structural_load", model)
"""
settings = {
"name": name,
"ifc_class": ifc_class,
}
return file.create_entity(settings["ifc_class"], Name=settings["name"])
return file.create_entity(ifc_class, Name=name)
@@ -19,7 +19,9 @@
import ifcopenshell.api
def add_structural_load_case(file, name="Unnamed", action_type="NOTDEFINED", action_source="NOTDEFINED") -> None:
def add_structural_load_case(
file: ifcopenshell.file, name: str = "Unnamed", action_type: str = "NOTDEFINED", action_source: str = "NOTDEFINED"
) -> ifcopenshell.entity_instance:
"""Adds a new load case, which is a collection of related load groups
:param name: The name of the load case
@@ -34,19 +36,14 @@ def add_structural_load_case(file, name="Unnamed", action_type="NOTDEFINED", act
:return: The new IfcStructuralLoadCase
:rtype: ifcopenshell.entity_instance
"""
settings = {
"name": name,
"action_type": action_type,
"action_source": action_source,
}
load_case = ifcopenshell.api.run(
"root.create_entity",
file,
ifc_class="IfcStructuralLoadCase",
predefined_type="LOAD_CASE",
name=settings["name"],
name=name
)
load_case.ActionType = settings["action_type"]
load_case.ActionSource = settings["action_source"]
load_case.ActionType = action_type
load_case.ActionSource = action_source
return load_case
@@ -19,7 +19,9 @@
import ifcopenshell.api
def add_structural_load_group(file, name="Unnamed", action_type="NOTDEFINED", action_source="NOTDEFINED") -> None:
def add_structural_load_group(
file: ifcopenshell.file, name: str = "Unnamed", action_type: str = "NOTDEFINED", action_source: str = "NOTDEFINED"
) -> ifcopenshell.entity_instance:
"""Adds a new load group, which is a collection of related loads
:param name: The name of the load group
@@ -34,19 +36,14 @@ def add_structural_load_group(file, name="Unnamed", action_type="NOTDEFINED", ac
:return: The new IfcStructuralLoadCase
:rtype: ifcopenshell.entity_instance
"""
settings = {
"name": name,
"action_type": action_type,
"action_source": action_source,
}
load_group = ifcopenshell.api.run(
"root.create_entity",
file,
ifc_class="IfcStructuralLoadGroup",
predefined_type="LOAD_GROUP",
name=settings["name"],
name=name,
)
load_group.ActionType = settings["action_type"]
load_group.ActionSource = settings["action_source"]
load_group.ActionType = action_type
load_group.ActionSource = action_source
return load_group
@@ -20,7 +20,11 @@ import ifcopenshell
import ifcopenshell.api
def add_structural_member_connection(file, relating_structural_member=None, related_structural_connection=None) -> None:
def add_structural_member_connection(
file: ifcopenshell.file,
relating_structural_member: ifcopenshell.entity_instance,
related_structural_connection: ifcopenshell.entity_instance,
) -> ifcopenshell.entity_instance:
"""Relates a structural member and a structural connection
:param relating_structural_member: The IfcStructuralMember to have a
@@ -39,7 +43,7 @@ def add_structural_member_connection(file, relating_structural_member=None, rela
for connection in settings["related_structural_connection"].ConnectsStructuralMembers or []:
if connection.RelatingStructuralMember == settings["relating_structural_member"]:
return
return connection
rel = ifcopenshell.api.run("root.create_entity", file, ifc_class="IfcRelConnectsStructuralMember")
rel.RelatingStructuralMember = settings["relating_structural_member"]
rel.RelatedStructuralConnection = settings["related_structural_connection"]
@@ -21,7 +21,11 @@ import ifcopenshell.api
import ifcopenshell.guid
def assign_structural_analysis_model(file, product=None, structural_analysis_model=None) -> None:
def assign_structural_analysis_model(
file: ifcopenshell.file,
product: ifcopenshell.entity_instance,
structural_analysis_model: ifcopenshell.entity_instance,
) -> ifcopenshell.entity_instance:
"""Assigns a load or structural member to an analysis model
:param product: The structural element that is part of the analysis.
@@ -52,3 +56,4 @@ def assign_structural_analysis_model(file, product=None, structural_analysis_mod
related_objects.add(settings["product"])
rel.RelatedObjects = list(related_objects)
ifcopenshell.api.run("owner.update_owner_history", file, **{"element": rel})
return rel
@@ -15,9 +15,13 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import ifcopenshell
from typing import Any
def edit_structural_analysis_model(file, structural_analysis_model=None, attributes=None) -> None:
def edit_structural_analysis_model(
file: ifcopenshell.file, structural_analysis_model: ifcopenshell.entity_instance, attributes: dict[str, Any]
) -> None:
"""Edits the attributes of an IfcStructuralAnalysisModel
For more information about the attributes and data types of an
@@ -26,7 +30,7 @@ def edit_structural_analysis_model(file, structural_analysis_model=None, attribu
:param structural_analysis_model: The IfcStructuralAnalysisModel entity you want to edit
:type structural_analysis_model: ifcopenshell.entity_instance
:param attributes: a dictionary of attribute names and values.
:type attributes: dict, optional
:type attributes: dict
:return: None
:rtype: None
"""
@@ -15,9 +15,13 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import ifcopenshell
from typing import Any
def edit_structural_boundary_condition(file, condition=None, attributes=None) -> None:
def edit_structural_boundary_condition(
file: ifcopenshell.file, condition: ifcopenshell.entity_instance, attributes: dict[str, Any]
) -> None:
"""Edits the attributes of an IfcBoundaryCondition
For more information about the attributes and data types of an
@@ -26,11 +30,11 @@ def edit_structural_boundary_condition(file, condition=None, attributes=None) ->
:param condition: The IfcBoundaryCondition entity you want to edit
:type condition: ifcopenshell.entity_instance
:param attributes: a dictionary of attribute names and values.
:type attributes: dict, optional
:type attributes: dict
:return: None
:rtype: None
"""
settings = {"condition": condition, "attributes": attributes or {}}
settings = {"condition": condition, "attributes": attributes}
for name, data in settings["attributes"].items():
if data["type"] == "string" or data["type"] == "null":
@@ -15,26 +15,32 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import ifcopenshell
def edit_structural_connection_cs(file, structural_item=None, axis=None, ref_direction=None) -> None:
def edit_structural_connection_cs(
file: ifcopenshell.file,
structural_item: ifcopenshell.entity_instance,
axis: tuple[float, float, float] = (0.0, 0.0, 1.0),
ref_direction: tuple[float, float, float] = (1.0, 0.0, 0.0),
) -> None:
"""Edits the coordinate system of a structural connection
:param structural_item: The IfcStructuralItem you want to modify.
:type structural_item: ifcopenshell.entity_instance
:param axis: The unit Z axis vector defined as a list of 3 floats.
Defaults to [0., 0., 1.].
:type axis: list[float]
Defaults to (0., 0., 1.).
:type axis: tuple[float, float, float]
:param ref_direction: The unit X axis vector defined as a list of 3
floats. Defaults to [1., 0., 0.].
:type ref_direction: list[float]
floats. Defaults to (1., 0., 0.).
:type ref_direction: tuple[float, float, float]
:return: None
:rtype: None
"""
settings = {
"structural_item": structural_item,
"axis": axis or [0.0, 0.0, 1.0],
"ref_direction": ref_direction or [1.0, 0.0, 0.0],
"axis": axis,
"ref_direction": ref_direction,
}
if settings["structural_item"].ConditionCoordinateSystem is None:
@@ -15,20 +15,25 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import ifcopenshell
def edit_structural_item_axis(file, structural_item=None, axis=None) -> None:
def edit_structural_item_axis(
file: ifcopenshell.file,
structural_item: ifcopenshell.entity_instance,
axis: tuple[float, float, float] = (0.0, 0.0, 1.0),
) -> None:
"""Edits the coordinate system of a structural connection
:param structural_item: The IfcStructuralItem you want to modify.
:type structural_item: ifcopenshell.entity_instance
:param axis: The unit Z axis vector defined as a list of 3 floats.
Defaults to [0., 0., 1.].
:type axis: list[float]
Defaults to (0., 0., 1.).
:type axis: tuple[float, float, float]
:return: None
:rtype: None
"""
settings = {"structural_item": structural_item, "axis": axis or [0.0, 0.0, 1.0]}
settings = {"structural_item": structural_item, "axis": axis}
if len(file.get_inverse(settings["structural_item"].Axis)) == 1:
file.remove(settings["structural_item"].Axis)
@@ -15,9 +15,13 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import ifcopenshell
from typing import Any
def edit_structural_load(file, structural_load=None, attributes=None) -> None:
def edit_structural_load(
file: ifcopenshell.file, structural_load: ifcopenshell.entity_instance, attributes: dict[str, Any]
) -> None:
"""Edits the attributes of an IfcStructuralLoad
For more information about the attributes and data types of an
@@ -26,7 +30,7 @@ def edit_structural_load(file, structural_load=None, attributes=None) -> None:
:param structural_load: The IfcStructuralLoad entity you want to edit
:type structural_load: ifcopenshell.entity_instance
:param attributes: a dictionary of attribute names and values.
:type attributes: dict, optional
:type attributes: dict
:return: None
:rtype: None
"""
@@ -15,9 +15,13 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import ifcopenshell
from typing import Any
def edit_structural_load_case(file, load_case=None, attributes=None) -> None:
def edit_structural_load_case(
file: ifcopenshell.file, load_case: ifcopenshell.entity_instance, attributes: dict[str, Any]
) -> None:
"""Edits the attributes of an IfcStructuralLoadCase
For more information about the attributes and data types of an
@@ -26,7 +30,7 @@ def edit_structural_load_case(file, load_case=None, attributes=None) -> None:
:param load_case: The IfcStructuralLoadCase entity you want to edit
:type load_case: ifcopenshell.entity_instance
:param attributes: a dictionary of attribute names and values.
:type attributes: dict, optional
:type attributes: dict
:return: None
:rtype: None
"""
@@ -20,7 +20,9 @@ import ifcopenshell
import ifcopenshell.util.element
def remove_structural_analysis_model(file, structural_analysis_model=None) -> None:
def remove_structural_analysis_model(
file: ifcopenshell.file, structural_analysis_model: ifcopenshell.entity_instance
) -> None:
"""Removes an analysis model
Note that the contents of an analysis model are currently preserved.
@@ -15,16 +15,22 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import ifcopenshell
from typing import Optional
def remove_structural_boundary_condition(file, connection=None, boundary_condition=None) -> None:
def remove_structural_boundary_condition(
file: ifcopenshell.file,
connection: Optional[ifcopenshell.entity_instance] = None,
boundary_condition: Optional[ifcopenshell.entity_instance] = None,
) -> None:
"""Removes a condition from a connection, or an orphased boundary condition
:param connection: The IfcStructuralConnection to remove the condition
from. If omitted, it is assumed to be an orphaned condition.
:type connection: ifcopenshell.entity_instance,optional
:param boundary_condition: The IfcBoundaryCondition to remove.
:type boundary_condition: ifcopenshell.entity_instance
:type boundary_condition: ifcopenshell.entity_instance, optional.
:return: None
:rtype: None
"""
@@ -21,7 +21,7 @@ import ifcopenshell.api
import ifcopenshell.util.element
def remove_structural_connection_condition(file, relation=None) -> None:
def remove_structural_connection_condition(file: ifcopenshell.file, relation: ifcopenshell.entity_instance) -> None:
"""Removes a relationship between a connection and a condition
The condition and the member itself is preserved.
@@ -15,9 +15,10 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import ifcopenshell
def remove_structural_load(file, structural_load=None) -> None:
def remove_structural_load(file: ifcopenshell.file, structural_load: ifcopenshell.entity_instance) -> None:
"""Removes a structural load
:param structural_load: The IfcStructuralLoad to remove.
@@ -21,7 +21,7 @@ import ifcopenshell.api
import ifcopenshell.util.element
def remove_structural_load_case(file, load_case=None) -> None:
def remove_structural_load_case(file: ifcopenshell.file, load_case: ifcopenshell.entity_instance) -> None:
"""Removes a structural load case
:param load_case: The IfcStructuralLoadCase to remove.
@@ -21,7 +21,7 @@ import ifcopenshell.api
import ifcopenshell.util.element
def remove_structural_load_group(file, load_group=None) -> None:
def remove_structural_load_group(file: ifcopenshell.file, load_group: ifcopenshell.entity_instance) -> None:
"""Removes a structural load group
:param load_group: The IfcStructuralLoadGroup to remove.
@@ -21,7 +21,11 @@ import ifcopenshell.api
import ifcopenshell.util.element
def unassign_structural_analysis_model(file, product=None, structural_analysis_model=None) -> None:
def unassign_structural_analysis_model(
file: ifcopenshell.file,
product: ifcopenshell.entity_instance,
structural_analysis_model: ifcopenshell.entity_instance,
) -> None:
"""Removes a relationship between a structural element and the analysis model
:param product: The structural element that is part of the analysis.