mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 01:41:57 +00:00
you can now add, edit and remove structural load cases
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import ifcopenshell.api
|
||||
|
||||
class Usecase:
|
||||
def __init__(self, file, **settings):
|
||||
self.file = file
|
||||
self.settings = {
|
||||
"name": "Unnamed",
|
||||
"predefined_type": "LOAD_CASE",
|
||||
"action_type": "NOTDEFINED",
|
||||
"action_source": "NOTDEFINED",
|
||||
}
|
||||
for key, value in settings.items():
|
||||
self.settings[key] = value
|
||||
|
||||
def execute(self):
|
||||
load_case = ifcopenshell.api.run(
|
||||
"root.create_entity",
|
||||
self.file,
|
||||
ifc_class="IfcStructuralLoadCase",
|
||||
predefined_type=self.settings["predefined_type"],
|
||||
action_type=self.settings["action_type"],
|
||||
action_source=self.settings["action_source"],
|
||||
name=self.settings["name"],
|
||||
)
|
||||
return load_case
|
||||
@@ -6,6 +6,12 @@ class Data:
|
||||
boundary_conditions = {}
|
||||
connects_structural_members = {}
|
||||
|
||||
load_cases = {}
|
||||
# load_case_combinations = {}
|
||||
# load_groups = {}
|
||||
# structural_activities = {}
|
||||
# connects_structural_activities = {}
|
||||
|
||||
@classmethod
|
||||
def purge(cls):
|
||||
cls.is_loaded = False
|
||||
@@ -14,6 +20,7 @@ class Data:
|
||||
cls.connections = {}
|
||||
cls.boundary_conditions = {}
|
||||
cls.connects_structural_members = {}
|
||||
cls.load_cases = {}
|
||||
|
||||
@classmethod
|
||||
def load(cls, file, product_id=None):
|
||||
@@ -23,6 +30,7 @@ class Data:
|
||||
if product_id:
|
||||
return cls.load_structural_connection(product_id)
|
||||
cls.load_structural_analysis_models()
|
||||
cls.load_structural_load_cases()
|
||||
cls.is_loaded = True
|
||||
|
||||
@classmethod
|
||||
@@ -53,6 +61,27 @@ class Data:
|
||||
|
||||
cls.structural_analysis_models[model.id()] = data
|
||||
|
||||
@classmethod
|
||||
def load_structural_load_cases(cls):
|
||||
cls.load_cases = {}
|
||||
|
||||
for case in cls._file.by_type("IfcStructuralLoadCase"):
|
||||
# if case.IsGroupedBy:
|
||||
# for rel in case.IsGroupedBy:
|
||||
# for product in rel.RelatedObjects:
|
||||
# cls.products.setdefault(product.id(), []).append(case.id())
|
||||
data = case.get_info()
|
||||
del data["OwnerHistory"]
|
||||
|
||||
is_grouped_by = []
|
||||
for load_group in case.IsGroupedBy or []:
|
||||
is_grouped_by.append(load_group.id())
|
||||
data["IsGroupedBy"] = is_grouped_by
|
||||
|
||||
cls.load_cases[case.id()] = data
|
||||
|
||||
print(data)
|
||||
|
||||
@classmethod
|
||||
def load_structural_connection(cls, product_id):
|
||||
cls.connections = {}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
class Usecase:
|
||||
def __init__(self, file, **settings):
|
||||
self.file = file
|
||||
self.settings = {"load_case": None, "attributes": {}}
|
||||
for key, value in settings.items():
|
||||
self.settings[key] = value
|
||||
|
||||
def execute(self):
|
||||
for name, value in self.settings["attributes"].items():
|
||||
setattr(self.settings["load_case"], name, value)
|
||||
@@ -0,0 +1,15 @@
|
||||
import ifcopenshell.api
|
||||
|
||||
|
||||
class Usecase:
|
||||
def __init__(self, file, **settings):
|
||||
self.file = file
|
||||
self.settings = {"load_case": None}
|
||||
for key, value in settings.items():
|
||||
self.settings[key] = value
|
||||
|
||||
def execute(self):
|
||||
# TODO: do a deep purge
|
||||
for rel in self.settings["load_case"].IsGroupedBy or []:
|
||||
self.file.remove(rel)
|
||||
self.file.remove(self.settings["load_case"])
|
||||
Reference in New Issue
Block a user