mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
Generate functions for all API usecases for better static code features. See #2693.
This commit is contained in:
@@ -15,3 +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/>.
|
||||
|
||||
from .add_structural_activity import add_structural_activity
|
||||
from .add_structural_analysis_model import add_structural_analysis_model
|
||||
from .add_structural_boundary_condition import add_structural_boundary_condition
|
||||
from .add_structural_load import add_structural_load
|
||||
from .add_structural_load_case import add_structural_load_case
|
||||
from .add_structural_load_group import add_structural_load_group
|
||||
from .add_structural_member_connection import add_structural_member_connection
|
||||
from .assign_structural_analysis_model import assign_structural_analysis_model
|
||||
from .edit_structural_analysis_model import edit_structural_analysis_model
|
||||
from .edit_structural_boundary_condition import edit_structural_boundary_condition
|
||||
from .edit_structural_connection_cs import edit_structural_connection_cs
|
||||
from .edit_structural_item_axis import edit_structural_item_axis
|
||||
from .edit_structural_load import edit_structural_load
|
||||
from .edit_structural_load_case import edit_structural_load_case
|
||||
from .remove_structural_analysis_model import remove_structural_analysis_model
|
||||
from .remove_structural_boundary_condition import remove_structural_boundary_condition
|
||||
from .remove_structural_connection_condition import remove_structural_connection_condition
|
||||
from .remove_structural_load import remove_structural_load
|
||||
from .remove_structural_load_case import remove_structural_load_case
|
||||
from .remove_structural_load_group import remove_structural_load_group
|
||||
from .unassign_structural_analysis_model import unassign_structural_analysis_model
|
||||
|
||||
@@ -19,65 +19,61 @@
|
||||
import ifcopenshell.api
|
||||
|
||||
|
||||
class Usecase:
|
||||
def __init__(
|
||||
self,
|
||||
def add_structural_activity(
|
||||
file,
|
||||
ifc_class="IfcStructuralPlanarAction",
|
||||
predefined_type="CONST",
|
||||
global_or_local="GLOBAL_COORDS",
|
||||
applied_load=None,
|
||||
structural_member=None,
|
||||
) -> None:
|
||||
"""Adds a new structural activity
|
||||
|
||||
A structural activity is either a structural action or a reaction. It
|
||||
may be applied to a point, a curve, or a planar surface, and may be a
|
||||
constant load, linear, etc.
|
||||
|
||||
The activity must be defined using an applied load, and associated with
|
||||
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.run(
|
||||
"root.create_entity",
|
||||
file,
|
||||
ifc_class="IfcStructuralPlanarAction",
|
||||
predefined_type="CONST",
|
||||
global_or_local="GLOBAL_COORDS",
|
||||
applied_load=None,
|
||||
structural_member=None,
|
||||
):
|
||||
"""Adds a new structural activity
|
||||
ifc_class=settings["ifc_class"],
|
||||
predefined_type=settings["predefined_type"],
|
||||
)
|
||||
activity.AppliedLoad = settings["applied_load"]
|
||||
activity.GlobalOrLocal = settings["global_or_local"]
|
||||
|
||||
A structural activity is either a structural action or a reaction. It
|
||||
may be applied to a point, a curve, or a planar surface, and may be a
|
||||
constant load, linear, etc.
|
||||
|
||||
The activity must be defined using an applied load, and associated with
|
||||
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
|
||||
"""
|
||||
self.file = file
|
||||
self.settings = {
|
||||
"ifc_class": ifc_class,
|
||||
"predefined_type": predefined_type,
|
||||
"global_or_local": global_or_local,
|
||||
"applied_load": applied_load,
|
||||
"structural_member": structural_member,
|
||||
}
|
||||
|
||||
def execute(self):
|
||||
activity = ifcopenshell.api.run(
|
||||
"root.create_entity",
|
||||
self.file,
|
||||
ifc_class=self.settings["ifc_class"],
|
||||
predefined_type=self.settings["predefined_type"],
|
||||
)
|
||||
activity.AppliedLoad = self.settings["applied_load"]
|
||||
activity.GlobalOrLocal = self.settings["global_or_local"]
|
||||
|
||||
rel = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcRelConnectsStructuralActivity")
|
||||
rel.RelatingElement = self.settings["structural_member"]
|
||||
rel.RelatedStructuralActivity = activity
|
||||
return activity
|
||||
rel = ifcopenshell.api.run("root.create_entity", file, ifc_class="IfcRelConnectsStructuralActivity")
|
||||
rel.RelatingElement = settings["structural_member"]
|
||||
rel.RelatedStructuralActivity = activity
|
||||
return activity
|
||||
|
||||
+17
-20
@@ -20,30 +20,27 @@ import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
|
||||
|
||||
class Usecase:
|
||||
def __init__(self, file):
|
||||
"""Add a new structural analysis model
|
||||
def add_structural_analysis_model(file) -> None:
|
||||
"""Add a new structural analysis model
|
||||
|
||||
A structural analysis model is a group of all the loads, reactions,
|
||||
structural members, and structural connections required to describe a
|
||||
structural analysis model.
|
||||
A structural analysis model is a group of all the loads, reactions,
|
||||
structural members, and structural connections required to describe a
|
||||
structural analysis model.
|
||||
|
||||
A 3D analytical model is assumed.
|
||||
A 3D analytical model is assumed.
|
||||
|
||||
:return: The newly created IfcStructuralAnalysisModel
|
||||
:rtype: ifcopenshell.entity_instance
|
||||
:return: The newly created IfcStructuralAnalysisModel
|
||||
:rtype: ifcopenshell.entity_instance
|
||||
|
||||
Example:
|
||||
Example:
|
||||
|
||||
.. code:: python
|
||||
.. code:: python
|
||||
|
||||
# Create a fresh blank structural analysis
|
||||
analysis = ifcopenshell.api.run("structural.add_structural_analysis_model", model)
|
||||
"""
|
||||
self.file = file
|
||||
self.settings = {}
|
||||
# Create a fresh blank structural analysis
|
||||
analysis = ifcopenshell.api.run("structural.add_structural_analysis_model", model)
|
||||
"""
|
||||
settings = {}
|
||||
|
||||
def execute(self):
|
||||
return ifcopenshell.api.run(
|
||||
"root.create_entity", self.file, ifc_class="IfcStructuralAnalysisModel", predefined_type="LOADING_3D"
|
||||
)
|
||||
return ifcopenshell.api.run(
|
||||
"root.create_entity", file, ifc_class="IfcStructuralAnalysisModel", predefined_type="LOADING_3D"
|
||||
)
|
||||
|
||||
+40
-45
@@ -17,55 +17,50 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
class Usecase:
|
||||
def __init__(self, file, name=None, connection=None, ifc_class="IfcBoundaryNodeCondition"):
|
||||
"""Adds a new structural boundary condition to a structural connection
|
||||
def add_structural_boundary_condition(file, name=None, connection=None, ifc_class="IfcBoundaryNodeCondition") -> None:
|
||||
"""Adds a new structural boundary condition to a structural connection
|
||||
|
||||
The type of boundary condition depends on the connection. Point
|
||||
connections will have a node condition, curve connections will have an
|
||||
edge condition, and surface connections will have a face condition.
|
||||
The type of boundary condition depends on the connection. Point
|
||||
connections will have a node condition, curve connections will have an
|
||||
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
|
||||
: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:
|
||||
Example:
|
||||
|
||||
.. code:: python
|
||||
.. code:: python
|
||||
|
||||
ifcopenshell.api.run("structural.add_structural_boundary_condition", model, connection=connection)
|
||||
"""
|
||||
self.file = file
|
||||
self.settings = {"name": name, "connection": connection, "ifc_class": ifc_class}
|
||||
ifcopenshell.api.run("structural.add_structural_boundary_condition", model, connection=connection)
|
||||
"""
|
||||
settings = {"name": name, "connection": connection, "ifc_class": ifc_class}
|
||||
|
||||
def execute(self):
|
||||
if self.settings["connection"]:
|
||||
# assign boundary condition to a connection
|
||||
if self.settings["connection"].is_a("IfcRelConnectsStructuralMember"):
|
||||
related_connection = self.settings["connection"].RelatedStructuralConnection
|
||||
else:
|
||||
related_connection = self.settings["connection"]
|
||||
|
||||
if related_connection.is_a("IfcStructuralPointConnection"):
|
||||
boundary_class = "IfcBoundaryNodeCondition"
|
||||
elif related_connection.is_a("IfcStructuralCurveConnection"):
|
||||
boundary_class = "IfcBoundaryEdgeCondition"
|
||||
elif related_connection.is_a("IfcStructuralSurfaceConnection"):
|
||||
boundary_class = "IfcBoundaryFaceCondition"
|
||||
|
||||
self.settings["connection"].AppliedCondition = self.file.create_entity(
|
||||
boundary_class, Name=self.settings["name"]
|
||||
)
|
||||
if settings["connection"]:
|
||||
# assign boundary condition to a connection
|
||||
if settings["connection"].is_a("IfcRelConnectsStructuralMember"):
|
||||
related_connection = settings["connection"].RelatedStructuralConnection
|
||||
else:
|
||||
# add an orphan boundary condition
|
||||
return self.file.create_entity(self.settings["ifc_class"], Name=self.settings["name"])
|
||||
related_connection = settings["connection"]
|
||||
|
||||
if related_connection.is_a("IfcStructuralPointConnection"):
|
||||
boundary_class = "IfcBoundaryNodeCondition"
|
||||
elif related_connection.is_a("IfcStructuralCurveConnection"):
|
||||
boundary_class = "IfcBoundaryEdgeCondition"
|
||||
elif related_connection.is_a("IfcStructuralSurfaceConnection"):
|
||||
boundary_class = "IfcBoundaryFaceCondition"
|
||||
|
||||
settings["connection"].AppliedCondition = file.create_entity(boundary_class, Name=settings["name"])
|
||||
else:
|
||||
# add an orphan boundary condition
|
||||
return file.create_entity(settings["ifc_class"], Name=settings["name"])
|
||||
|
||||
@@ -19,35 +19,32 @@
|
||||
import ifcopenshell.api
|
||||
|
||||
|
||||
class Usecase:
|
||||
def __init__(self, file, name=None, ifc_class="IfcStructuralLoadLinearForce"):
|
||||
"""Adds a new structural load
|
||||
def add_structural_load(file, name=None, ifc_class="IfcStructuralLoadLinearForce") -> None:
|
||||
"""Adds a new structural load
|
||||
|
||||
Structural loads may be actions or reactions. A simple load might be a
|
||||
static and be linear, planar, or a single point. Alternatively, loads
|
||||
may be defined as a configuration of multiple loads.
|
||||
Structural loads may be actions or reactions. A simple load might be a
|
||||
static and be linear, planar, or a single point. Alternatively, loads
|
||||
may be defined as a configuration of multiple loads.
|
||||
|
||||
:param name: The name of the load
|
||||
:type name: str,optional
|
||||
:param ifc_class: The subtype of IfcStructuralLoad to create. Consult
|
||||
the IFC documentation to see all the types of loads.
|
||||
:type ifc_class: str
|
||||
:return: The newly created load entity, depending on the ifc_class
|
||||
specified.
|
||||
:rtype: ifcopenshell.entity_instance
|
||||
:param name: The name of the load
|
||||
:type name: str,optional
|
||||
:param ifc_class: The subtype of IfcStructuralLoad to create. Consult
|
||||
the IFC documentation to see all the types of loads.
|
||||
:type ifc_class: str
|
||||
:return: The newly created load entity, depending on the ifc_class
|
||||
specified.
|
||||
:rtype: ifcopenshell.entity_instance
|
||||
|
||||
Example:
|
||||
Example:
|
||||
|
||||
.. code:: python
|
||||
.. code:: python
|
||||
|
||||
# Create a simple linear load
|
||||
ifcopenshell.api.run("structural.add_structural_load", model)
|
||||
"""
|
||||
self.file = file
|
||||
self.settings = {
|
||||
"name": name,
|
||||
"ifc_class": ifc_class,
|
||||
}
|
||||
# Create a simple linear load
|
||||
ifcopenshell.api.run("structural.add_structural_load", model)
|
||||
"""
|
||||
settings = {
|
||||
"name": name,
|
||||
"ifc_class": ifc_class,
|
||||
}
|
||||
|
||||
def execute(self):
|
||||
return self.file.create_entity(self.settings["ifc_class"], Name=self.settings["name"])
|
||||
return file.create_entity(settings["ifc_class"], Name=settings["name"])
|
||||
|
||||
@@ -19,39 +19,34 @@
|
||||
import ifcopenshell.api
|
||||
|
||||
|
||||
class Usecase:
|
||||
def __init__(
|
||||
self, file, name="Unnamed", action_type="NOTDEFINED", action_source="NOTDEFINED"
|
||||
):
|
||||
"""Adds a new load case, which is a collection of related load groups
|
||||
def add_structural_load_case(file, name="Unnamed", action_type="NOTDEFINED", action_source="NOTDEFINED") -> None:
|
||||
"""Adds a new load case, which is a collection of related load groups
|
||||
|
||||
:param name: The name of the load case
|
||||
:type name: str
|
||||
:param action_type: Choose from EXTRAORDINARY_A, PERMANENT_G,
|
||||
or VARIABLE_Q, taken from the Eurocode standard.
|
||||
:type action_type: str
|
||||
:param action_source: The source of the load case, such as DEAD_LOAD_G,
|
||||
LIVE_LOAD_Q, TRANSPORT, ICE, etc. For the full list consult
|
||||
IfcActionSourceTypeEnum in the IFC documentation.
|
||||
:type action_source: str
|
||||
:return: The new IfcStructuralLoadCase
|
||||
:rtype: ifcopenshell.entity_instance
|
||||
"""
|
||||
self.file = file
|
||||
self.settings = {
|
||||
"name": name,
|
||||
"action_type": action_type,
|
||||
"action_source": action_source,
|
||||
}
|
||||
:param name: The name of the load case
|
||||
:type name: str
|
||||
:param action_type: Choose from EXTRAORDINARY_A, PERMANENT_G,
|
||||
or VARIABLE_Q, taken from the Eurocode standard.
|
||||
:type action_type: str
|
||||
:param action_source: The source of the load case, such as DEAD_LOAD_G,
|
||||
LIVE_LOAD_Q, TRANSPORT, ICE, etc. For the full list consult
|
||||
IfcActionSourceTypeEnum in the IFC documentation.
|
||||
:type action_source: str
|
||||
:return: The new IfcStructuralLoadCase
|
||||
:rtype: ifcopenshell.entity_instance
|
||||
"""
|
||||
settings = {
|
||||
"name": name,
|
||||
"action_type": action_type,
|
||||
"action_source": action_source,
|
||||
}
|
||||
|
||||
def execute(self):
|
||||
load_case = ifcopenshell.api.run(
|
||||
"root.create_entity",
|
||||
self.file,
|
||||
ifc_class="IfcStructuralLoadCase",
|
||||
predefined_type="LOAD_CASE",
|
||||
name=self.settings["name"],
|
||||
)
|
||||
load_case.ActionType = self.settings["action_type"]
|
||||
load_case.ActionSource = self.settings["action_source"]
|
||||
return load_case
|
||||
load_case = ifcopenshell.api.run(
|
||||
"root.create_entity",
|
||||
file,
|
||||
ifc_class="IfcStructuralLoadCase",
|
||||
predefined_type="LOAD_CASE",
|
||||
name=settings["name"],
|
||||
)
|
||||
load_case.ActionType = settings["action_type"]
|
||||
load_case.ActionSource = settings["action_source"]
|
||||
return load_case
|
||||
|
||||
@@ -19,39 +19,34 @@
|
||||
import ifcopenshell.api
|
||||
|
||||
|
||||
class Usecase:
|
||||
def __init__(
|
||||
self, file, name="Unnamed", action_type="NOTDEFINED", action_source="NOTDEFINED"
|
||||
):
|
||||
"""Adds a new load group, which is a collection of related loads
|
||||
def add_structural_load_group(file, name="Unnamed", action_type="NOTDEFINED", action_source="NOTDEFINED") -> None:
|
||||
"""Adds a new load group, which is a collection of related loads
|
||||
|
||||
:param name: The name of the load group
|
||||
:type name: str
|
||||
:param action_type: Choose from EXTRAORDINARY_A, PERMANENT_G,
|
||||
or VARIABLE_Q, taken from the Eurocode standard.
|
||||
:type action_type: str
|
||||
:param action_source: The source of the load case, such as DEAD_LOAD_G,
|
||||
LIVE_LOAD_Q, TRANSPORT, ICE, etc. For the full list consult
|
||||
IfcActionSourceTypeEnum in the IFC documentation.
|
||||
:type action_source: str
|
||||
:return: The new IfcStructuralLoadCase
|
||||
:rtype: ifcopenshell.entity_instance
|
||||
"""
|
||||
self.file = file
|
||||
self.settings = {
|
||||
"name": name,
|
||||
"action_type": action_type,
|
||||
"action_source": action_source,
|
||||
}
|
||||
:param name: The name of the load group
|
||||
:type name: str
|
||||
:param action_type: Choose from EXTRAORDINARY_A, PERMANENT_G,
|
||||
or VARIABLE_Q, taken from the Eurocode standard.
|
||||
:type action_type: str
|
||||
:param action_source: The source of the load case, such as DEAD_LOAD_G,
|
||||
LIVE_LOAD_Q, TRANSPORT, ICE, etc. For the full list consult
|
||||
IfcActionSourceTypeEnum in the IFC documentation.
|
||||
:type action_source: str
|
||||
:return: The new IfcStructuralLoadCase
|
||||
:rtype: ifcopenshell.entity_instance
|
||||
"""
|
||||
settings = {
|
||||
"name": name,
|
||||
"action_type": action_type,
|
||||
"action_source": action_source,
|
||||
}
|
||||
|
||||
def execute(self):
|
||||
load_group = ifcopenshell.api.run(
|
||||
"root.create_entity",
|
||||
self.file,
|
||||
ifc_class="IfcStructuralLoadGroup",
|
||||
predefined_type="LOAD_GROUP",
|
||||
name=self.settings["name"],
|
||||
)
|
||||
load_group.ActionType = self.settings["action_type"]
|
||||
load_group.ActionSource = self.settings["action_source"]
|
||||
return load_group
|
||||
load_group = ifcopenshell.api.run(
|
||||
"root.create_entity",
|
||||
file,
|
||||
ifc_class="IfcStructuralLoadGroup",
|
||||
predefined_type="LOAD_GROUP",
|
||||
name=settings["name"],
|
||||
)
|
||||
load_group.ActionType = settings["action_type"]
|
||||
load_group.ActionSource = settings["action_source"]
|
||||
return load_group
|
||||
|
||||
+22
-25
@@ -20,30 +20,27 @@ import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
|
||||
|
||||
class Usecase:
|
||||
def __init__(self, file, relating_structural_member=None, related_structural_connection=None):
|
||||
"""Relates a structural member and a structural connection
|
||||
def add_structural_member_connection(file, relating_structural_member=None, related_structural_connection=None) -> None:
|
||||
"""Relates a structural member and a structural 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
|
||||
"""
|
||||
self.file = file
|
||||
self.settings = {
|
||||
"relating_structural_member": relating_structural_member,
|
||||
"related_structural_connection": related_structural_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,
|
||||
}
|
||||
|
||||
def execute(self):
|
||||
for connection in self.settings["related_structural_connection"].ConnectsStructuralMembers or []:
|
||||
if connection.RelatingStructuralMember == self.settings["relating_structural_member"]:
|
||||
return
|
||||
rel = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcRelConnectsStructuralMember")
|
||||
rel.RelatingStructuralMember = self.settings["relating_structural_member"]
|
||||
rel.RelatedStructuralConnection = self.settings["related_structural_connection"]
|
||||
return rel
|
||||
for connection in settings["related_structural_connection"].ConnectsStructuralMembers or []:
|
||||
if connection.RelatingStructuralMember == settings["relating_structural_member"]:
|
||||
return
|
||||
rel = ifcopenshell.api.run("root.create_entity", file, ifc_class="IfcRelConnectsStructuralMember")
|
||||
rel.RelatingStructuralMember = settings["relating_structural_member"]
|
||||
rel.RelatedStructuralConnection = settings["related_structural_connection"]
|
||||
return rel
|
||||
|
||||
+29
-32
@@ -20,37 +20,34 @@ import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
|
||||
|
||||
class Usecase:
|
||||
def __init__(self, file, product=None, structural_analysis_model=None):
|
||||
"""Assigns a load or structural member to an analysis model
|
||||
def assign_structural_analysis_model(file, product=None, structural_analysis_model=None) -> None:
|
||||
"""Assigns a load or structural member to an analysis model
|
||||
|
||||
:param product: The structural element that is part of the analysis.
|
||||
:type product: ifcopenshell.entity_instance
|
||||
:param structural_analysis_model: The IfcStructuralAnalysisModel that
|
||||
the structural element is related to.
|
||||
:type structural_analysis_model: ifcopenshell.entity_instance
|
||||
:return: The IfcRelAssignsToGroup relationship
|
||||
:rtype: ifcopenshell.entity_instance
|
||||
"""
|
||||
self.file = file
|
||||
self.settings = {
|
||||
"product": product,
|
||||
"structural_analysis_model": structural_analysis_model,
|
||||
}
|
||||
:param product: The structural element that is part of the analysis.
|
||||
:type product: ifcopenshell.entity_instance
|
||||
:param structural_analysis_model: The IfcStructuralAnalysisModel that
|
||||
the structural element is related to.
|
||||
:type structural_analysis_model: ifcopenshell.entity_instance
|
||||
:return: The IfcRelAssignsToGroup relationship
|
||||
:rtype: ifcopenshell.entity_instance
|
||||
"""
|
||||
settings = {
|
||||
"product": product,
|
||||
"structural_analysis_model": structural_analysis_model,
|
||||
}
|
||||
|
||||
def execute(self):
|
||||
if not self.settings["structural_analysis_model"].IsGroupedBy:
|
||||
return self.file.create_entity(
|
||||
"IfcRelAssignsToGroup",
|
||||
**{
|
||||
"GlobalId": ifcopenshell.guid.new(),
|
||||
"OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", self.file),
|
||||
"RelatedObjects": [self.settings["product"]],
|
||||
"RelatingGroup": self.settings["structural_analysis_model"],
|
||||
}
|
||||
)
|
||||
rel = self.settings["structural_analysis_model"].IsGroupedBy[0]
|
||||
related_objects = set(rel.RelatedObjects) or set()
|
||||
related_objects.add(self.settings["product"])
|
||||
rel.RelatedObjects = list(related_objects)
|
||||
ifcopenshell.api.run("owner.update_owner_history", self.file, **{"element": rel})
|
||||
if not settings["structural_analysis_model"].IsGroupedBy:
|
||||
return file.create_entity(
|
||||
"IfcRelAssignsToGroup",
|
||||
**{
|
||||
"GlobalId": ifcopenshell.guid.new(),
|
||||
"OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", file),
|
||||
"RelatedObjects": [settings["product"]],
|
||||
"RelatingGroup": settings["structural_analysis_model"],
|
||||
}
|
||||
)
|
||||
rel = settings["structural_analysis_model"].IsGroupedBy[0]
|
||||
related_objects = set(rel.RelatedObjects) or set()
|
||||
related_objects.add(settings["product"])
|
||||
rel.RelatedObjects = list(related_objects)
|
||||
ifcopenshell.api.run("owner.update_owner_history", file, **{"element": rel})
|
||||
|
||||
+15
-18
@@ -17,24 +17,21 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
class Usecase:
|
||||
def __init__(self, file, structural_analysis_model=None, attributes=None):
|
||||
"""Edits the attributes of an IfcStructuralAnalysisModel
|
||||
def edit_structural_analysis_model(file, structural_analysis_model=None, attributes=None) -> None:
|
||||
"""Edits the attributes of an IfcStructuralAnalysisModel
|
||||
|
||||
For more information about the attributes and data types of an
|
||||
IfcStructuralAnalysisModel, consult the IFC documentation.
|
||||
For more information about the attributes and data types of an
|
||||
IfcStructuralAnalysisModel, consult the IFC documentation.
|
||||
|
||||
: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
|
||||
:return: None
|
||||
:rtype: None
|
||||
"""
|
||||
self.file = file
|
||||
self.settings = {"structural_analysis_model": structural_analysis_model, "attributes": attributes or {}}
|
||||
: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
|
||||
:return: None
|
||||
:rtype: None
|
||||
"""
|
||||
settings = {"structural_analysis_model": structural_analysis_model, "attributes": attributes or {}}
|
||||
|
||||
def execute(self):
|
||||
for name, value in self.settings["attributes"].items():
|
||||
setattr(self.settings["structural_analysis_model"], name, value)
|
||||
return self.settings["structural_analysis_model"]
|
||||
for name, value in settings["attributes"].items():
|
||||
setattr(settings["structural_analysis_model"], name, value)
|
||||
return settings["structural_analysis_model"]
|
||||
|
||||
+20
-23
@@ -17,29 +17,26 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
class Usecase:
|
||||
def __init__(self, file, condition=None, attributes=None):
|
||||
"""Edits the attributes of an IfcBoundaryCondition
|
||||
def edit_structural_boundary_condition(file, condition=None, attributes=None) -> None:
|
||||
"""Edits the attributes of an IfcBoundaryCondition
|
||||
|
||||
For more information about the attributes and data types of an
|
||||
IfcBoundaryCondition, consult the IFC documentation.
|
||||
For more information about the attributes and data types of an
|
||||
IfcBoundaryCondition, consult the IFC documentation.
|
||||
|
||||
: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
|
||||
:return: None
|
||||
:rtype: None
|
||||
"""
|
||||
self.file = file
|
||||
self.settings = {"condition": condition, "attributes": attributes or {}}
|
||||
: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
|
||||
:return: None
|
||||
:rtype: None
|
||||
"""
|
||||
settings = {"condition": condition, "attributes": attributes or {}}
|
||||
|
||||
def execute(self):
|
||||
for name, data in self.settings["attributes"].items():
|
||||
if data["type"] == "string" or data["type"] == "null":
|
||||
value = data["value"]
|
||||
elif data["type"] == "IfcBoolean":
|
||||
value = self.file.createIfcBoolean(data["value"])
|
||||
else:
|
||||
value = self.file.create_entity(data["type"], data["value"])
|
||||
setattr(self.settings["condition"], name, value)
|
||||
for name, data in settings["attributes"].items():
|
||||
if data["type"] == "string" or data["type"] == "null":
|
||||
value = data["value"]
|
||||
elif data["type"] == "IfcBoolean":
|
||||
value = file.createIfcBoolean(data["value"])
|
||||
else:
|
||||
value = file.create_entity(data["type"], data["value"])
|
||||
setattr(settings["condition"], name, value)
|
||||
|
||||
+29
-32
@@ -17,38 +17,35 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
class Usecase:
|
||||
def __init__(self, file, structural_item=None, axis=None, ref_direction=None):
|
||||
"""Edits the coordinate system of a structural connection
|
||||
def edit_structural_connection_cs(file, structural_item=None, axis=None, ref_direction=None) -> 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]
|
||||
: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]
|
||||
:return: None
|
||||
:rtype: None
|
||||
"""
|
||||
self.file = file
|
||||
self.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],
|
||||
}
|
||||
: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]
|
||||
: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]
|
||||
: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],
|
||||
}
|
||||
|
||||
def execute(self):
|
||||
if self.settings["structural_item"].ConditionCoordinateSystem is None:
|
||||
point = self.file.createIfcCartesianPoint((0.0, 0.0, 0.0))
|
||||
ccs = self.file.createIfcAxis2Placement3D(point, None, None)
|
||||
self.settings["structural_item"].ConditionCoordinateSystem = ccs
|
||||
if settings["structural_item"].ConditionCoordinateSystem is None:
|
||||
point = file.createIfcCartesianPoint((0.0, 0.0, 0.0))
|
||||
ccs = file.createIfcAxis2Placement3D(point, None, None)
|
||||
settings["structural_item"].ConditionCoordinateSystem = ccs
|
||||
|
||||
ccs = self.settings["structural_item"].ConditionCoordinateSystem
|
||||
if ccs.Axis and len(self.file.get_inverse(ccs.Axis)) == 1:
|
||||
self.file.remove(ccs.Axis)
|
||||
ccs.Axis = self.file.createIfcDirection(self.settings["axis"])
|
||||
if ccs.RefDirection and len(self.file.get_inverse(ccs.RefDirection)) == 1:
|
||||
self.file.remove(ccs.RefDirection)
|
||||
ccs.RefDirection = self.file.createIfcDirection(self.settings["ref_direction"])
|
||||
ccs = settings["structural_item"].ConditionCoordinateSystem
|
||||
if ccs.Axis and len(file.get_inverse(ccs.Axis)) == 1:
|
||||
file.remove(ccs.Axis)
|
||||
ccs.Axis = file.createIfcDirection(settings["axis"])
|
||||
if ccs.RefDirection and len(file.get_inverse(ccs.RefDirection)) == 1:
|
||||
file.remove(ccs.RefDirection)
|
||||
ccs.RefDirection = file.createIfcDirection(settings["ref_direction"])
|
||||
|
||||
@@ -17,22 +17,19 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
class Usecase:
|
||||
def __init__(self, file, structural_item=None, axis=None):
|
||||
"""Edits the coordinate system of a structural connection
|
||||
def edit_structural_item_axis(file, structural_item=None, axis=None) -> 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]
|
||||
:return: None
|
||||
:rtype: None
|
||||
"""
|
||||
self.file = file
|
||||
self.settings = {"structural_item": structural_item, "axis": axis or [0.0, 0.0, 1.0]}
|
||||
: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]
|
||||
:return: None
|
||||
:rtype: None
|
||||
"""
|
||||
settings = {"structural_item": structural_item, "axis": axis or [0.0, 0.0, 1.0]}
|
||||
|
||||
def execute(self):
|
||||
if len(self.file.get_inverse(self.settings["structural_item"].Axis)) == 1:
|
||||
self.file.remove(self.settings["structural_item"].Axis)
|
||||
self.settings["structural_item"].Axis = self.file.createIfcDirection(self.settings["axis"])
|
||||
if len(file.get_inverse(settings["structural_item"].Axis)) == 1:
|
||||
file.remove(settings["structural_item"].Axis)
|
||||
settings["structural_item"].Axis = file.createIfcDirection(settings["axis"])
|
||||
|
||||
@@ -17,23 +17,20 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
class Usecase:
|
||||
def __init__(self, file, structural_load=None, attributes=None):
|
||||
"""Edits the attributes of an IfcStructuralLoad
|
||||
def edit_structural_load(file, structural_load=None, attributes=None) -> None:
|
||||
"""Edits the attributes of an IfcStructuralLoad
|
||||
|
||||
For more information about the attributes and data types of an
|
||||
IfcStructuralLoad, consult the IFC documentation.
|
||||
For more information about the attributes and data types of an
|
||||
IfcStructuralLoad, consult the IFC documentation.
|
||||
|
||||
: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
|
||||
:return: None
|
||||
:rtype: None
|
||||
"""
|
||||
self.file = file
|
||||
self.settings = {"structural_load": structural_load, "attributes": attributes or {}}
|
||||
: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
|
||||
:return: None
|
||||
:rtype: None
|
||||
"""
|
||||
settings = {"structural_load": structural_load, "attributes": attributes or {}}
|
||||
|
||||
def execute(self):
|
||||
for name, value in self.settings["attributes"].items():
|
||||
setattr(self.settings["structural_load"], name, value)
|
||||
for name, value in settings["attributes"].items():
|
||||
setattr(settings["structural_load"], name, value)
|
||||
|
||||
@@ -17,23 +17,20 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
class Usecase:
|
||||
def __init__(self, file, load_case=None, attributes=None):
|
||||
"""Edits the attributes of an IfcStructuralLoadCase
|
||||
def edit_structural_load_case(file, load_case=None, attributes=None) -> None:
|
||||
"""Edits the attributes of an IfcStructuralLoadCase
|
||||
|
||||
For more information about the attributes and data types of an
|
||||
IfcStructuralLoadCase, consult the IFC documentation.
|
||||
For more information about the attributes and data types of an
|
||||
IfcStructuralLoadCase, consult the IFC documentation.
|
||||
|
||||
: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
|
||||
:return: None
|
||||
:rtype: None
|
||||
"""
|
||||
self.file = file
|
||||
self.settings = {"load_case": load_case, "attributes": attributes or {}}
|
||||
: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
|
||||
:return: None
|
||||
:rtype: None
|
||||
"""
|
||||
settings = {"load_case": load_case, "attributes": attributes or {}}
|
||||
|
||||
def execute(self):
|
||||
for name, value in self.settings["attributes"].items():
|
||||
setattr(self.settings["load_case"], name, value)
|
||||
for name, value in settings["attributes"].items():
|
||||
setattr(settings["load_case"], name, value)
|
||||
|
||||
+18
-21
@@ -20,28 +20,25 @@ import ifcopenshell
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
class Usecase:
|
||||
def __init__(self, file, structural_analysis_model=None):
|
||||
"""Removes an analysis model
|
||||
def remove_structural_analysis_model(file, structural_analysis_model=None) -> None:
|
||||
"""Removes an analysis model
|
||||
|
||||
Note that the contents of an analysis model are currently preserved.
|
||||
Note that the contents of an analysis model are currently preserved.
|
||||
|
||||
:param structural_analysis_model: The IfcStructuralAnalysisModel to
|
||||
remove.
|
||||
:type structural_analysis_model: ifcopenshell.entity_instance
|
||||
:return: None
|
||||
:rtype: None
|
||||
"""
|
||||
self.file = file
|
||||
self.settings = {"structural_analysis_model": structural_analysis_model}
|
||||
:param structural_analysis_model: The IfcStructuralAnalysisModel to
|
||||
remove.
|
||||
:type structural_analysis_model: ifcopenshell.entity_instance
|
||||
:return: None
|
||||
:rtype: None
|
||||
"""
|
||||
settings = {"structural_analysis_model": structural_analysis_model}
|
||||
|
||||
def execute(self):
|
||||
for rel in self.settings["structural_analysis_model"].IsGroupedBy or []:
|
||||
history = rel.OwnerHistory
|
||||
self.file.remove(rel)
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
history = self.settings["structural_analysis_model"].OwnerHistory
|
||||
self.file.remove(self.settings["structural_analysis_model"])
|
||||
for rel in settings["structural_analysis_model"].IsGroupedBy or []:
|
||||
history = rel.OwnerHistory
|
||||
file.remove(rel)
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
ifcopenshell.util.element.remove_deep2(file, history)
|
||||
history = settings["structural_analysis_model"].OwnerHistory
|
||||
file.remove(settings["structural_analysis_model"])
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(file, history)
|
||||
|
||||
+23
-26
@@ -17,31 +17,28 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
class Usecase:
|
||||
def __init__(self, file, connection=None, boundary_condition=None):
|
||||
"""Removes a condition from a connection, or an orphased boundary condition
|
||||
def remove_structural_boundary_condition(file, connection=None, boundary_condition=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
|
||||
:return: None
|
||||
:rtype: None
|
||||
"""
|
||||
self.file = file
|
||||
self.settings = {"connection": connection, "boundary_condition": 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
|
||||
:return: None
|
||||
:rtype: None
|
||||
"""
|
||||
settings = {"connection": connection, "boundary_condition": boundary_condition}
|
||||
|
||||
def execute(self):
|
||||
if self.settings["connection"]:
|
||||
# remove boundary condition from a connection
|
||||
if not self.settings["connection"].AppliedCondition:
|
||||
return
|
||||
if len(self.file.get_inverse(self.settings["connection"].AppliedCondition)) == 1:
|
||||
self.file.remove(self.settings["connection"].AppliedCondition)
|
||||
self.settings["connection"].AppliedCondition = None
|
||||
else:
|
||||
# remove the boundary condition
|
||||
for conn in self.file.get_inverse(self.settings["boundary_condition"]):
|
||||
conn.AppliedCondition = None
|
||||
self.file.remove(self.settings["boundary_condition"])
|
||||
if settings["connection"]:
|
||||
# remove boundary condition from a connection
|
||||
if not settings["connection"].AppliedCondition:
|
||||
return
|
||||
if len(file.get_inverse(settings["connection"].AppliedCondition)) == 1:
|
||||
file.remove(settings["connection"].AppliedCondition)
|
||||
settings["connection"].AppliedCondition = None
|
||||
else:
|
||||
# remove the boundary condition
|
||||
for conn in file.get_inverse(settings["boundary_condition"]):
|
||||
conn.AppliedCondition = None
|
||||
file.remove(settings["boundary_condition"])
|
||||
|
||||
+19
-22
@@ -21,28 +21,25 @@ import ifcopenshell.api
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
class Usecase:
|
||||
def __init__(self, file, relation=None):
|
||||
"""Removes a relationship between a connection and a condition
|
||||
def remove_structural_connection_condition(file, relation=None) -> None:
|
||||
"""Removes a relationship between a connection and a condition
|
||||
|
||||
The condition and the member itself is preserved.
|
||||
The condition and the member itself is preserved.
|
||||
|
||||
:param relation: The IfcRelConnectsStructuralMember to remove.
|
||||
:type relation: ifcopenshell.entity_instance
|
||||
:return: None
|
||||
:rtype: None
|
||||
"""
|
||||
self.file = file
|
||||
self.settings = {"relation": relation}
|
||||
:param relation: The IfcRelConnectsStructuralMember to remove.
|
||||
:type relation: ifcopenshell.entity_instance
|
||||
:return: None
|
||||
:rtype: None
|
||||
"""
|
||||
settings = {"relation": relation}
|
||||
|
||||
def execute(self):
|
||||
if self.settings["relation"].AppliedCondition:
|
||||
ifcopenshell.api.run(
|
||||
"structural.remove_structural_boundary_condition",
|
||||
self.file,
|
||||
connection=self.settings["relation"].RelatedStructuralConnection
|
||||
)
|
||||
history = self.settings["relation"].OwnerHistory
|
||||
self.file.remove(self.settings["relation"])
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
if settings["relation"].AppliedCondition:
|
||||
ifcopenshell.api.run(
|
||||
"structural.remove_structural_boundary_condition",
|
||||
file,
|
||||
connection=settings["relation"].RelatedStructuralConnection,
|
||||
)
|
||||
history = settings["relation"].OwnerHistory
|
||||
file.remove(settings["relation"])
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(file, history)
|
||||
|
||||
@@ -17,17 +17,14 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
class Usecase:
|
||||
def __init__(self, file, structural_load=None):
|
||||
"""Removes a structural load
|
||||
def remove_structural_load(file, structural_load=None) -> None:
|
||||
"""Removes a structural load
|
||||
|
||||
:param structural_load: The IfcStructuralLoad to remove.
|
||||
:type structural_load: ifcopenshell.entity_instance
|
||||
:return: None
|
||||
:rtype: None
|
||||
"""
|
||||
self.file = file
|
||||
self.settings = {"structural_load": structural_load}
|
||||
:param structural_load: The IfcStructuralLoad to remove.
|
||||
:type structural_load: ifcopenshell.entity_instance
|
||||
:return: None
|
||||
:rtype: None
|
||||
"""
|
||||
settings = {"structural_load": structural_load}
|
||||
|
||||
def execute(self):
|
||||
self.file.remove(self.settings["structural_load"])
|
||||
file.remove(settings["structural_load"])
|
||||
|
||||
+17
-20
@@ -21,25 +21,22 @@ import ifcopenshell.api
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
class Usecase:
|
||||
def __init__(self, file, load_case=None):
|
||||
"""Removes a structural load case
|
||||
def remove_structural_load_case(file, load_case=None) -> None:
|
||||
"""Removes a structural load case
|
||||
|
||||
:param load_case: The IfcStructuralLoadCase to remove.
|
||||
:type load_case: ifcopenshell.entity_instance
|
||||
:return: None
|
||||
:rtype: None
|
||||
"""
|
||||
self.file = file
|
||||
self.settings = {"load_case": load_case}
|
||||
:param load_case: The IfcStructuralLoadCase to remove.
|
||||
:type load_case: ifcopenshell.entity_instance
|
||||
:return: None
|
||||
:rtype: None
|
||||
"""
|
||||
settings = {"load_case": load_case}
|
||||
|
||||
def execute(self):
|
||||
# TODO: do a deep purge
|
||||
for rel in self.settings["load_case"].IsGroupedBy or []:
|
||||
history = rel.OwnerHistory
|
||||
self.file.remove(rel)
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
history = self.settings["load_case"].OwnerHistory
|
||||
self.file.remove(self.settings["load_case"])
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
# TODO: do a deep purge
|
||||
for rel in settings["load_case"].IsGroupedBy or []:
|
||||
history = rel.OwnerHistory
|
||||
file.remove(rel)
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(file, history)
|
||||
history = settings["load_case"].OwnerHistory
|
||||
file.remove(settings["load_case"])
|
||||
ifcopenshell.util.element.remove_deep2(file, history)
|
||||
|
||||
+19
-22
@@ -21,27 +21,24 @@ import ifcopenshell.api
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
class Usecase:
|
||||
def __init__(self, file, load_group=None):
|
||||
"""Removes a structural load group
|
||||
def remove_structural_load_group(file, load_group=None) -> None:
|
||||
"""Removes a structural load group
|
||||
|
||||
:param load_group: The IfcStructuralLoadGroup to remove.
|
||||
:type load_group: ifcopenshell.entity_instance
|
||||
:return: None
|
||||
:rtype: None
|
||||
"""
|
||||
self.file = file
|
||||
self.settings = {"load_group": load_group}
|
||||
:param load_group: The IfcStructuralLoadGroup to remove.
|
||||
:type load_group: ifcopenshell.entity_instance
|
||||
:return: None
|
||||
:rtype: None
|
||||
"""
|
||||
settings = {"load_group": load_group}
|
||||
|
||||
def execute(self):
|
||||
# TODO: do a deep purge
|
||||
for inverse in self.file.get_inverse(self.settings["load_group"]):
|
||||
if inverse.is_a("IfcRelAssignsToGroup") and len(inverse.RelatedObjects) == 1:
|
||||
history = inverse.OwnerHistory
|
||||
self.file.remove(inverse)
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
history = self.settings["load_group"].OwnerHistory
|
||||
self.file.remove(self.settings["load_group"])
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
# TODO: do a deep purge
|
||||
for inverse in file.get_inverse(settings["load_group"]):
|
||||
if inverse.is_a("IfcRelAssignsToGroup") and len(inverse.RelatedObjects) == 1:
|
||||
history = inverse.OwnerHistory
|
||||
file.remove(inverse)
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(file, history)
|
||||
history = settings["load_group"].OwnerHistory
|
||||
file.remove(settings["load_group"])
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(file, history)
|
||||
|
||||
+27
-30
@@ -21,35 +21,32 @@ import ifcopenshell.api
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
class Usecase:
|
||||
def __init__(self, file, product=None, structural_analysis_model=None):
|
||||
"""Removes a relationship between a structural element and the analysis model
|
||||
def unassign_structural_analysis_model(file, product=None, structural_analysis_model=None) -> None:
|
||||
"""Removes a relationship between a structural element and the analysis model
|
||||
|
||||
:param product: The structural element that is part of the analysis.
|
||||
:type product: ifcopenshell.entity_instance
|
||||
:param structural_analysis_model: The IfcStructuralAnalysisModel that
|
||||
the structural element is related to.
|
||||
:type structural_analysis_model: ifcopenshell.entity_instance
|
||||
:return: None
|
||||
:rtype: None
|
||||
"""
|
||||
self.file = file
|
||||
self.settings = {
|
||||
"product": product,
|
||||
"structural_analysis_model": structural_analysis_model,
|
||||
}
|
||||
:param product: The structural element that is part of the analysis.
|
||||
:type product: ifcopenshell.entity_instance
|
||||
:param structural_analysis_model: The IfcStructuralAnalysisModel that
|
||||
the structural element is related to.
|
||||
:type structural_analysis_model: ifcopenshell.entity_instance
|
||||
:return: None
|
||||
:rtype: None
|
||||
"""
|
||||
settings = {
|
||||
"product": product,
|
||||
"structural_analysis_model": structural_analysis_model,
|
||||
}
|
||||
|
||||
def execute(self):
|
||||
if not self.settings["structural_analysis_model"].IsGroupedBy:
|
||||
return
|
||||
rel = self.settings["structural_analysis_model"].IsGroupedBy[0]
|
||||
related_objects = set(rel.RelatedObjects) or set()
|
||||
related_objects.remove(self.settings["product"])
|
||||
if len(related_objects):
|
||||
rel.RelatedObjects = list(related_objects)
|
||||
ifcopenshell.api.run("owner.update_owner_history", self.file, **{"element": rel})
|
||||
else:
|
||||
history = rel.OwnerHistory
|
||||
self.file.remove(rel)
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
if not settings["structural_analysis_model"].IsGroupedBy:
|
||||
return
|
||||
rel = settings["structural_analysis_model"].IsGroupedBy[0]
|
||||
related_objects = set(rel.RelatedObjects) or set()
|
||||
related_objects.remove(settings["product"])
|
||||
if len(related_objects):
|
||||
rel.RelatedObjects = list(related_objects)
|
||||
ifcopenshell.api.run("owner.update_owner_history", file, **{"element": rel})
|
||||
else:
|
||||
history = rel.OwnerHistory
|
||||
file.remove(rel)
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(file, history)
|
||||
|
||||
Reference in New Issue
Block a user