mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 01:41:57 +00:00
Update to IfcResources panel and authoring subtypes of IfcConstructionResource with ifcopenshell.api
This commit is contained in:
@@ -7,6 +7,7 @@ class Usecase:
|
||||
def __init__(self, file, **settings):
|
||||
self.file = file
|
||||
self.settings = {
|
||||
"parent_resource": None,
|
||||
"name": "Unnamed",
|
||||
"predefined_type": "NOTDEFINED",
|
||||
}
|
||||
@@ -23,8 +24,13 @@ class Usecase:
|
||||
)
|
||||
# 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
|
||||
)
|
||||
if self.settings["parent_resource"]:
|
||||
ifcopenshell.api.run(
|
||||
"nest.assign_object", self.file, related_object=resource, relating_object=self.settings["parent_resource"]
|
||||
)
|
||||
else:
|
||||
context = self.file.by_type("IfcContext")[0]
|
||||
ifcopenshell.api.run(
|
||||
"project.assign_declaration", self.file, definition=crew_resource, relating_context=context
|
||||
)
|
||||
return crew_resource
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell
|
||||
|
||||
|
||||
class Usecase:
|
||||
def __init__(self, file, **settings):
|
||||
self.file = file
|
||||
self.settings = {
|
||||
"parent_resource": None,
|
||||
}
|
||||
for key, value in settings.items():
|
||||
self.settings[key] = value
|
||||
|
||||
def execute(self):
|
||||
equipment_resource = ifcopenshell.api.run(
|
||||
"root.create_entity",
|
||||
self.file,
|
||||
ifc_class="IfcConstructionEquipmentResource",
|
||||
name=None,
|
||||
predefined_type="NOTDEFINED",
|
||||
identification="none",
|
||||
)
|
||||
if self.settings["parent_resource"]:
|
||||
ifcopenshell.api.run(
|
||||
"nest.assign_object", self.file, related_object=equipment_resource, relating_object=self.settings["parent_resource"]
|
||||
)
|
||||
return equipment_resource
|
||||
@@ -0,0 +1,27 @@
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell
|
||||
|
||||
|
||||
class Usecase:
|
||||
def __init__(self, file, **settings):
|
||||
self.file = file
|
||||
self.settings = {
|
||||
"parent_resource": None,
|
||||
}
|
||||
for key, value in settings.items():
|
||||
self.settings[key] = value
|
||||
|
||||
def execute(self):
|
||||
labor_resource = ifcopenshell.api.run(
|
||||
"root.create_entity",
|
||||
self.file,
|
||||
ifc_class="IfcLaborResource",
|
||||
name=None,
|
||||
predefined_type="NOTDEFINED",
|
||||
identification="none",
|
||||
)
|
||||
if self.settings["parent_resource"]:
|
||||
ifcopenshell.api.run(
|
||||
"nest.assign_object", self.file, related_object=labor_resource, relating_object=self.settings["parent_resource"]
|
||||
)
|
||||
return labor_resource
|
||||
@@ -0,0 +1,27 @@
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell
|
||||
|
||||
|
||||
class Usecase:
|
||||
def __init__(self, file, **settings):
|
||||
self.file = file
|
||||
self.settings = {
|
||||
"parent_resource": None,
|
||||
}
|
||||
for key, value in settings.items():
|
||||
self.settings[key] = value
|
||||
|
||||
def execute(self):
|
||||
material_resource = ifcopenshell.api.run(
|
||||
"root.create_entity",
|
||||
self.file,
|
||||
ifc_class="IfcConstructionMaterialResource",
|
||||
name=None,
|
||||
predefined_type="NOTDEFINED",
|
||||
identification="none",
|
||||
)
|
||||
if self.settings["parent_resource"]:
|
||||
ifcopenshell.api.run(
|
||||
"nest.assign_object", self.file, related_object=material_resource, relating_object=self.settings["parent_resource"]
|
||||
)
|
||||
return material_resource
|
||||
@@ -0,0 +1,27 @@
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell
|
||||
|
||||
|
||||
class Usecase:
|
||||
def __init__(self, file, **settings):
|
||||
self.file = file
|
||||
self.settings = {
|
||||
"parent_resource": None,
|
||||
}
|
||||
for key, value in settings.items():
|
||||
self.settings[key] = value
|
||||
|
||||
def execute(self):
|
||||
product_resource = ifcopenshell.api.run(
|
||||
"root.create_entity",
|
||||
self.file,
|
||||
ifc_class="IfcConstructionProductResource",
|
||||
name=None,
|
||||
predefined_type="NOTDEFINED",
|
||||
identification="none",
|
||||
)
|
||||
if self.settings["parent_resource"]:
|
||||
ifcopenshell.api.run(
|
||||
"nest.assign_object", self.file, related_object=product_resource, relating_object=self.settings["parent_resource"]
|
||||
)
|
||||
return product_resource
|
||||
@@ -7,6 +7,7 @@ class Usecase:
|
||||
def __init__(self, file, **settings):
|
||||
self.file = file
|
||||
self.settings = {
|
||||
"parent_resource": None,
|
||||
"name": "Unnamed",
|
||||
"predefined_type": "NOTDEFINED",
|
||||
}
|
||||
@@ -23,8 +24,13 @@ class Usecase:
|
||||
)
|
||||
# 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=subcontract_resource, relating_context=context
|
||||
)
|
||||
if self.settings["parent_resource"]:
|
||||
ifcopenshell.api.run(
|
||||
"nest.assign_object", self.file, related_object=resource, relating_object=self.settings["parent_resource"]
|
||||
)
|
||||
else:
|
||||
context = self.file.by_type("IfcContext")[0]
|
||||
ifcopenshell.api.run(
|
||||
"project.assign_declaration", self.file, definition=subcontract_resource, relating_context=context
|
||||
)
|
||||
return subcontract_resource
|
||||
|
||||
@@ -19,5 +19,4 @@ class Data:
|
||||
for rel in resource.IsNestedBy:
|
||||
[data["RelatedObjects"].append(o.id()) for o in rel.RelatedObjects if o.is_a("IfcCrewResource") or o.is_a("IfcsubcontractResource")]
|
||||
cls.resources[resource.id()] = data
|
||||
|
||||
cls.is_loaded=True
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
class Usecase:
|
||||
def __init__(self, file, **settings):
|
||||
self.file = file
|
||||
self.settings = {"resource": 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["resource"], name, value)
|
||||
Reference in New Issue
Block a user