mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-22 05:00:53 +00:00
Types in type dropdowns are now sorted alphabetically for convenience.
This commit is contained in:
@@ -61,7 +61,7 @@ class BimTool(WorkSpaceTool):
|
|||||||
row.label(text="No IFC Class")
|
row.label(text="No IFC Class")
|
||||||
else:
|
else:
|
||||||
row.prop(props, "ifc_class", text="")
|
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="")
|
row.prop(props, "relating_type", text="")
|
||||||
else:
|
else:
|
||||||
row.label(text="No Relating Type")
|
row.label(text="No Relating Type")
|
||||||
|
|||||||
@@ -58,11 +58,11 @@ def getIfcTypes(self, context):
|
|||||||
return type_classes_enum
|
return type_classes_enum
|
||||||
|
|
||||||
|
|
||||||
def getAvailableTypes(self, context):
|
def get_relating_type(self, context):
|
||||||
global available_types_enum
|
global available_types_enum
|
||||||
if len(available_types_enum) < 1 and getIfcTypes(self, context):
|
if len(available_types_enum) < 1 and getIfcTypes(self, context):
|
||||||
elements = IfcStore.get_file().by_type(self.ifc_class)
|
elements = [(str(e.id()), e.Name, "") for e in IfcStore.get_file().by_type(self.ifc_class)]
|
||||||
available_types_enum.extend((str(e.id()), e.Name, "") for e in elements)
|
available_types_enum.extend(sorted(elements, key=lambda s: s[1]))
|
||||||
return available_types_enum
|
return available_types_enum
|
||||||
|
|
||||||
|
|
||||||
@@ -82,11 +82,12 @@ def getApplicableTypes(self, context):
|
|||||||
return applicable_types_enum
|
return applicable_types_enum
|
||||||
|
|
||||||
|
|
||||||
def getRelatingTypes(self, context):
|
def get_object_relating_type(self, context):
|
||||||
global relating_types_enum
|
global relating_types_enum
|
||||||
if len(relating_types_enum) < 1:
|
if len(relating_types_enum) < 1:
|
||||||
elements = IfcStore.get_file().by_type(context.active_object.BIMTypeProperties.relating_type_class)
|
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
|
return relating_types_enum
|
||||||
|
|
||||||
|
|
||||||
@@ -99,10 +100,10 @@ def updateTypeDropdowns(self, context):
|
|||||||
|
|
||||||
class BIMTypeProperties(PropertyGroup):
|
class BIMTypeProperties(PropertyGroup):
|
||||||
ifc_class: bpy.props.EnumProperty(items=getIfcTypes, name="IFC Class", update=updateTypeInstanceIfcClass)
|
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):
|
class BIMTypeObjectProperties(PropertyGroup):
|
||||||
is_editing_type: BoolProperty(name="Is Editing Type", update=updateTypeDropdowns)
|
is_editing_type: BoolProperty(name="Is Editing Type", update=updateTypeDropdowns)
|
||||||
relating_type_class: EnumProperty(items=getApplicableTypes, name="Relating Type Class")
|
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 = self.layout.row(align=True)
|
||||||
|
|
||||||
row.prop(props, "relating_type_class", text="")
|
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.prop(props, "relating_type", text="")
|
||||||
row.operator("bim.assign_type", icon="CHECKMARK", text="")
|
row.operator("bim.assign_type", icon="CHECKMARK", text="")
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user