Types in type dropdowns are now sorted alphabetically for convenience.

This commit is contained in:
Dion Moult
2021-10-27 09:35:31 +11:00
parent 78e5016619
commit 80b8da629d
3 changed files with 10 additions and 9 deletions
@@ -61,7 +61,7 @@ class BimTool(WorkSpaceTool):
row.label(text="No IFC Class")
else:
row.prop(props, "ifc_class", text="")
if type_prop.getAvailableTypes(props, context):
if type_prop.get_relating_type(props, context):
row.prop(props, "relating_type", text="")
else:
row.label(text="No Relating Type")
@@ -58,11 +58,11 @@ def getIfcTypes(self, context):
return type_classes_enum
def getAvailableTypes(self, context):
def get_relating_type(self, context):
global available_types_enum
if len(available_types_enum) < 1 and getIfcTypes(self, context):
elements = IfcStore.get_file().by_type(self.ifc_class)
available_types_enum.extend((str(e.id()), e.Name, "") for e in elements)
elements = [(str(e.id()), e.Name, "") for e in IfcStore.get_file().by_type(self.ifc_class)]
available_types_enum.extend(sorted(elements, key=lambda s: s[1]))
return available_types_enum
@@ -82,11 +82,12 @@ def getApplicableTypes(self, context):
return applicable_types_enum
def getRelatingTypes(self, context):
def get_object_relating_type(self, context):
global relating_types_enum
if len(relating_types_enum) < 1:
elements = IfcStore.get_file().by_type(context.active_object.BIMTypeProperties.relating_type_class)
relating_types_enum.extend((str(e.id()), e.Name, "") for e in elements)
elements = [(str(e.id()), e.Name, "") for e in elements]
relating_types_enum.extend(sorted(elements, key=lambda s: s[1]))
return relating_types_enum
@@ -99,10 +100,10 @@ def updateTypeDropdowns(self, context):
class BIMTypeProperties(PropertyGroup):
ifc_class: bpy.props.EnumProperty(items=getIfcTypes, name="IFC Class", update=updateTypeInstanceIfcClass)
relating_type: bpy.props.EnumProperty(items=getAvailableTypes, name="Relating Type")
relating_type: bpy.props.EnumProperty(items=get_relating_type, name="Relating Type")
class BIMTypeObjectProperties(PropertyGroup):
is_editing_type: BoolProperty(name="Is Editing Type", update=updateTypeDropdowns)
relating_type_class: EnumProperty(items=getApplicableTypes, name="Relating Type Class")
relating_type: EnumProperty(items=getRelatingTypes, name="Relating Type")
relating_type: EnumProperty(items=get_object_relating_type, name="Relating Type")
@@ -69,7 +69,7 @@ class BIM_PT_type(Panel):
row = self.layout.row(align=True)
row.prop(props, "relating_type_class", text="")
if type_prop.getRelatingTypes(None, context):
if type_prop.get_object_relating_type(None, context):
row.prop(props, "relating_type", text="")
row.operator("bim.assign_type", icon="CHECKMARK", text="")
else: