mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-21 07:42:44 +00:00
Project libraries are now sorted alphabetically for convenience
This commit is contained in:
@@ -190,7 +190,7 @@ class RefreshLibrary(bpy.types.Operator):
|
|||||||
self.props.active_library_element = ""
|
self.props.active_library_element = ""
|
||||||
|
|
||||||
types = IfcStore.library_file.wrapped_data.types_with_super()
|
types = IfcStore.library_file.wrapped_data.types_with_super()
|
||||||
for importable_type in ["IfcTypeProduct", "IfcMaterial", "IfcCostSchedule", "IfcProfileDef"]:
|
for importable_type in sorted(["IfcTypeProduct", "IfcMaterial", "IfcCostSchedule", "IfcProfileDef"]):
|
||||||
if importable_type in types:
|
if importable_type in types:
|
||||||
new = self.props.library_elements.add()
|
new = self.props.library_elements.add()
|
||||||
new.name = importable_type
|
new.name = importable_type
|
||||||
@@ -213,12 +213,9 @@ class ChangeLibraryElement(bpy.types.Operator):
|
|||||||
[ifc_classes.add(e.is_a()) for e in elements]
|
[ifc_classes.add(e.is_a()) for e in elements]
|
||||||
self.props.library_elements.clear()
|
self.props.library_elements.clear()
|
||||||
if len(ifc_classes) == 1 and list(ifc_classes)[0] == self.element_name:
|
if len(ifc_classes) == 1 and list(ifc_classes)[0] == self.element_name:
|
||||||
for element in elements:
|
for name, element in sorted([(self.get_name(e), e) for e in elements]):
|
||||||
new = self.props.library_elements.add()
|
new = self.props.library_elements.add()
|
||||||
if element.is_a("IfcProfileDef"):
|
new.name = name
|
||||||
new.name = element.ProfileName or "Unnamed"
|
|
||||||
else:
|
|
||||||
new.name = element.Name or "Unnamed"
|
|
||||||
new.ifc_definition_id = element.id()
|
new.ifc_definition_id = element.id()
|
||||||
if IfcStore.library_file.schema == "IFC2X3" or not IfcStore.library_file.by_type("IfcProjectLibrary"):
|
if IfcStore.library_file.schema == "IFC2X3" or not IfcStore.library_file.by_type("IfcProjectLibrary"):
|
||||||
new.is_declared = False
|
new.is_declared = False
|
||||||
@@ -227,11 +224,16 @@ class ChangeLibraryElement(bpy.types.Operator):
|
|||||||
):
|
):
|
||||||
new.is_declared = True
|
new.is_declared = True
|
||||||
else:
|
else:
|
||||||
for ifc_class in ifc_classes:
|
for ifc_class in sorted(ifc_classes):
|
||||||
new = self.props.library_elements.add()
|
new = self.props.library_elements.add()
|
||||||
new.name = ifc_class
|
new.name = ifc_class
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
def get_name(self, element):
|
||||||
|
if element.is_a("IfcProfileDef"):
|
||||||
|
return element.ProfileName or "Unnamed"
|
||||||
|
return element.Name or "Unnamed"
|
||||||
|
|
||||||
|
|
||||||
class RewindLibrary(bpy.types.Operator):
|
class RewindLibrary(bpy.types.Operator):
|
||||||
bl_idname = "bim.rewind_library"
|
bl_idname = "bim.rewind_library"
|
||||||
|
|||||||
Reference in New Issue
Block a user