You can now import a cost schedule from an IFC project library

This commit is contained in:
Dion Moult
2021-08-10 09:35:09 +10:00
parent 4bf074f97a
commit 869bb22830
2 changed files with 20 additions and 8 deletions
@@ -12,21 +12,33 @@ class Usecase:
def execute(self):
self.added_elements = set()
if self.settings["element"].is_a("IfcTypeProduct"):
try:
self.file.by_guid(self.settings["element"].GlobalId)
return
except:
pass
return self.append_type_product()
elif self.settings["element"].is_a("IfcMaterial"):
if [e for e in self.file.by_type("IfcMaterial") if e.Name == self.settings["element"].Name]:
return
return self.append_material()
elif self.settings["element"].is_a("IfcCostSchedule"):
return self.append_cost_schedule()
def is_already_appended(self):
try:
self.file.by_guid(self.settings["element"].GlobalId)
return True
except:
return False
def append_material(self):
if [e for e in self.file.by_type("IfcMaterial") if e.Name == self.settings["element"].Name]:
return
return self.file.add(self.settings["element"])
def append_cost_schedule(self):
if self.is_already_appended():
return
self.whitelisted_inverse_attributes = {"IfcCostSchedule": ["Controls"], "IfcCostItem": ["IsNestedBy"]}
return self.add_element(self.settings["element"])
def append_type_product(self):
if self.is_already_appended():
return
self.whitelisted_inverse_attributes = {
"IfcObjectDefinition": ["HasAssociations"],
"IfcMaterialDefinition": ["HasExternalReferences", "HasProperties"],