You can now import profile definitions from a library

This commit is contained in:
Dion Moult
2021-08-14 12:05:59 +10:00
parent c2530b7a61
commit 305465a898
2 changed files with 13 additions and 2 deletions
@@ -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", "IfcCostSchedule"]:
for importable_type in ["IfcTypeProduct", "IfcMaterial", "IfcCostSchedule", "IfcProfileDef"]:
if importable_type in types:
new = self.props.library_elements.add()
new.name = importable_type
@@ -198,7 +198,10 @@ class ChangeLibraryElement(bpy.types.Operator):
if len(ifc_classes) == 1 and list(ifc_classes)[0] == self.element_name:
for element in elements:
new = self.props.library_elements.add()
new.name = element.Name or "Unnamed"
if element.is_a("IfcProfileDef"):
new.name = element.ProfileName or "Unnamed"
else:
new.name = element.Name or "Unnamed"
new.ifc_definition_id = element.id()
if IfcStore.library_file.schema == "IFC2X3" or not IfcStore.library_file.by_type("IfcProjectLibrary"):
new.is_declared = False
@@ -11,12 +11,15 @@ class Usecase:
def execute(self):
self.added_elements = set()
self.whitelisted_inverse_attributes = {}
if self.settings["element"].is_a("IfcTypeProduct"):
return self.append_type_product()
elif self.settings["element"].is_a("IfcMaterial"):
return self.append_material()
elif self.settings["element"].is_a("IfcCostSchedule"):
return self.append_cost_schedule()
elif self.settings["element"].is_a("IfcProfileDef"):
return self.append_profile_def()
def is_already_appended(self):
try:
@@ -36,6 +39,11 @@ class Usecase:
self.whitelisted_inverse_attributes = {"IfcCostSchedule": ["Controls"], "IfcCostItem": ["IsNestedBy"]}
return self.add_element(self.settings["element"])
def append_profile_def(self):
if [e for e in self.file.by_type("IfcProfileDef") if e.ProfileName == self.settings["element"].ProfileName]:
return
return self.add_element(self.settings["element"])
def append_type_product(self):
if self.is_already_appended():
return