Feature to Add Crew Resources and SubContract Resources with the ifcopenshell.api and blenderB

This commit is contained in:
bosonprojets
2021-04-23 06:38:11 +00:00
parent 18d7193efc
commit c7aa42bfd5
10 changed files with 400 additions and 1 deletions
@@ -0,0 +1,30 @@
import ifcopenshell.api
import ifcopenshell.util.date
from datetime import datetime
class Usecase:
def __init__(self, file, **settings):
self.file = file
self.settings = {
"name": "Unnamed",
"predefined_type": "NOTDEFINED",
}
for key, value in settings.items():
self.settings[key] = value
def execute(self):
crew_resource = ifcopenshell.api.run(
"root.create_entity",
self.file,
ifc_class="IfcCrewResource",
predefined_type=self.settings["predefined_type"],
name=self.settings["name"],
)
# TODO: this is an ambiguity by buildingSMART: Can we nest and IfcCrewResource under an ifcCrewResource ?
# See https://forums.buildingsmart.org/t/is-the-ifcCrewResource-project-declaration-mutually-exclusive-to-aggregation-within-a-relating-ifcworkplan/3510
context = self.file.by_type("IfcContext")[0]
ifcopenshell.api.run(
"project.assign_declaration", self.file, definition=crew_resource, relating_context=context
)
return crew_resource