Materials UI - suggest MODEL_VIEW context for assigning material style by default

Probably makes more sense than just "Model".
This commit is contained in:
Andrej730
2024-10-04 17:42:05 +05:00
parent 8aa1b68d3e
commit 13a6d5b64a
@@ -798,8 +798,13 @@ class EnableEditingMaterialStyle(bpy.types.Operator):
if not 0 <= props.active_material_index < len(props.materials):
return {"FINISHED"}
material = tool.Ifc.get().by_id(props.materials[props.active_material_index].ifc_definition_id)
ifc_file = tool.Ifc.get()
material = ifc_file.by_id(props.materials[props.active_material_index].ifc_definition_id)
if not material.HasRepresentation:
# MODEL_VIEW is probably the one that's used with the styles most frequently.
context = ifcopenshell.util.representation.get_context(ifc_file, "Model", "Body", "MODEL_VIEW")
if context:
props.contexts = str(context.id())
return {"FINISHED"}
rep = material.HasRepresentation[0].Representations[0] # IfcStyledRepresentation