mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-22 23:49:59 +00:00
edit style for rep item - fallback in case user has no styles #6764
Or if style was removed in the process of editing. And it seems now UI will never appear broken that way. Previously - https://files.catbox.moe/exhkln.png Currently - https://files.catbox.moe/r36be8.png
This commit is contained in:
@@ -2558,7 +2558,8 @@ class EnableEditingRepresentationItemStyle(bpy.types.Operator, tool.Ifc.Operator
|
|||||||
ifc_file = tool.Ifc.get()
|
ifc_file = tool.Ifc.get()
|
||||||
|
|
||||||
# set dropdown to currently active style
|
# set dropdown to currently active style
|
||||||
representation_item_id = props.active_item.ifc_definition_id
|
assert (active_item := props.active_item)
|
||||||
|
representation_item_id = active_item.ifc_definition_id
|
||||||
representation_item = ifc_file.by_id(representation_item_id)
|
representation_item = ifc_file.by_id(representation_item_id)
|
||||||
style = tool.Style.get_representation_item_style(representation_item)
|
style = tool.Style.get_representation_item_style(representation_item)
|
||||||
if style:
|
if style:
|
||||||
@@ -2577,8 +2578,14 @@ class EditRepresentationItemStyle(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
props.is_editing_item_style = False
|
props.is_editing_item_style = False
|
||||||
ifc_file = tool.Ifc.get()
|
ifc_file = tool.Ifc.get()
|
||||||
|
|
||||||
surface_style = ifc_file.by_id(int(props.representation_item_style))
|
surface_style_id = tool.Blender.get_enum_safe(props, "representation_item_style")
|
||||||
representation_item_id = props.active_item.ifc_definition_id
|
if surface_style_id in (None, "-"):
|
||||||
|
surface_style = None
|
||||||
|
else:
|
||||||
|
surface_style = ifc_file.by_id(int(props.representation_item_style))
|
||||||
|
|
||||||
|
assert (active_item := props.active_item)
|
||||||
|
representation_item_id = active_item.ifc_definition_id
|
||||||
representation_item = ifc_file.by_id(representation_item_id)
|
representation_item = ifc_file.by_id(representation_item_id)
|
||||||
|
|
||||||
tool.Style.assign_style_to_representation_item(representation_item, surface_style)
|
tool.Style.assign_style_to_representation_item(representation_item, surface_style)
|
||||||
|
|||||||
@@ -101,7 +101,9 @@ class MaterialsData:
|
|||||||
for s in tool.Ifc.get().by_type("IfcPresentationStyle")
|
for s in tool.Ifc.get().by_type("IfcPresentationStyle")
|
||||||
if (style_name := s.Name) is not None
|
if (style_name := s.Name) is not None
|
||||||
]
|
]
|
||||||
return natsorted(results, key=lambda i: i[1])
|
results = natsorted(results, key=lambda i: i[1])
|
||||||
|
results.insert(0, ("-", "No Surface Style", ""))
|
||||||
|
return results
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def material_styles_data(cls) -> dict[int, list[dict[str, Any]]]:
|
def material_styles_data(cls) -> dict[int, list[dict[str, Any]]]:
|
||||||
|
|||||||
Reference in New Issue
Block a user