mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 09:48:32 +00:00
You can now import a cost schedule from an IFC project library
This commit is contained in:
@@ -172,7 +172,7 @@ class RefreshLibrary(bpy.types.Operator):
|
||||
self.props.active_library_element = ""
|
||||
|
||||
types = IfcStore.library_file.wrapped_data.types_with_super()
|
||||
for importable_type in ["IfcTypeProduct", "IfcMaterial"]:
|
||||
for importable_type in ["IfcTypeProduct", "IfcMaterial", "IfcCostSchedule"]:
|
||||
if importable_type in types:
|
||||
new = self.props.library_elements.add()
|
||||
new.name = importable_type
|
||||
|
||||
@@ -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"],
|
||||
|
||||
Reference in New Issue
Block a user