mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-12 02:23:34 +00:00
Fix #2107. Materials and styles in the scene manager are now shown alphabetically
This commit is contained in:
@@ -56,15 +56,16 @@ class Material(blenderbim.core.tool.Material):
|
||||
def import_material_definitions(cls, material_type):
|
||||
props = bpy.context.scene.BIMMaterialProperties
|
||||
props.materials.clear()
|
||||
for material in tool.Ifc.get().by_type(material_type):
|
||||
get_name = lambda x: x.Name or "Unnamed"
|
||||
if material_type == "IfcMaterialLayerSet":
|
||||
get_name = lambda x: x.LayerSetName or "Unnamed"
|
||||
elif material_type == "IfcMaterialList":
|
||||
get_name = lambda x: "Unnamed"
|
||||
materials = sorted(tool.Ifc.get().by_type(material_type), key=get_name)
|
||||
for material in materials:
|
||||
new = props.materials.add()
|
||||
new.ifc_definition_id = material.id()
|
||||
if material.is_a("IfcMaterialLayerSet"):
|
||||
new.name = material.LayerSetName or "Unnamed"
|
||||
elif material.is_a("IfcMaterialList"):
|
||||
new.name = "Unnamed"
|
||||
else:
|
||||
new.name = material.Name or "Unnamed"
|
||||
new.name = get_name(material)
|
||||
new.total_elements = len(set(ifcopenshell.util.element.get_elements_by_material(tool.Ifc.get(), material)))
|
||||
|
||||
@classmethod
|
||||
|
||||
@@ -183,7 +183,8 @@ class Style(blenderbim.core.tool.Style):
|
||||
def import_presentation_styles(cls, style_type):
|
||||
props = bpy.context.scene.BIMStylesProperties
|
||||
props.styles.clear()
|
||||
for style in tool.Ifc.get().by_type(style_type):
|
||||
styles = sorted(tool.Ifc.get().by_type(style_type), key=lambda x: x.Name or "Unnamed")
|
||||
for style in styles:
|
||||
new = props.styles.add()
|
||||
new.ifc_definition_id = style.id()
|
||||
new.name = style.Name or "Unnamed"
|
||||
|
||||
Reference in New Issue
Block a user