Fix issue BrowseExternalStyle not selecting current external style in file manager

This commit is contained in:
Andrej730
2023-12-14 17:43:12 +05:00
parent 1251a7838a
commit c60fed8b58
2 changed files with 13 additions and 3 deletions
@@ -240,10 +240,17 @@ class BrowseExternalStyle(bpy.types.Operator):
description="Start file browsing directory",
default="",
)
active_surface_style_id: bpy.props.IntProperty(
description="Currently selected IfcSurfaceStyle ID to automatically select it in the file browser",
options={"HIDDEN", "SKIP_SAVE"},
)
def invoke(self, context, event):
mat = context.active_object.active_material
external_style = tool.Style.get_style_elements(mat).get("IfcExternallyDefinedSurfaceStyle", None)
external_style = None
if self.active_surface_style_id:
style = tool.Ifc.get().by_id(self.active_surface_style_id)
external_style = tool.Style.get_style_elements(style).get("IfcExternallyDefinedSurfaceStyle", None)
# automatically select previously selected external style in file browser
if external_style and self.filepath == "":
style_path = Path(tool.Ifc.resolve_uri(external_style.Location))
@@ -233,7 +233,10 @@ class BIM_PT_styles(Panel):
row.operator("bim.disable_editing_style", text="", icon="CANCEL")
def draw_externally_defined_surface_style(self):
self.layout.row().operator("bim.browse_external_style", icon="APPEND_BLEND", text="Append From Blend File")
row = self.layout.row()
op = row.operator("bim.browse_external_style", icon="APPEND_BLEND", text="Append From Blend File")
style = self.props.styles[self.props.active_style_index]
op.active_surface_style_id = style.ifc_definition_id
blenderbim.bim.helper.draw_attributes(self.props.external_style_attributes, self.layout)
row = self.layout.row(align=True)
row.operator("bim.edit_surface_style", text="Save External Style", icon="CHECKMARK")