Generate functions for all API usecases for better static code features. See #2693.

This commit is contained in:
Dion Moult
2024-05-06 14:35:39 +10:00
parent 10f894e2ea
commit d11ec67129
330 changed files with 13283 additions and 13751 deletions
@@ -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