From c60fed8b589a83166e367e28bee578227571ad12 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Thu, 14 Dec 2023 17:43:12 +0500 Subject: [PATCH] Fix issue BrowseExternalStyle not selecting current external style in file manager --- .../blenderbim/bim/module/style/operator.py | 11 +++++++++-- src/blenderbim/blenderbim/bim/module/style/ui.py | 5 ++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/blenderbim/blenderbim/bim/module/style/operator.py b/src/blenderbim/blenderbim/bim/module/style/operator.py index 68a163c65a..d59bfc18f8 100644 --- a/src/blenderbim/blenderbim/bim/module/style/operator.py +++ b/src/blenderbim/blenderbim/bim/module/style/operator.py @@ -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)) diff --git a/src/blenderbim/blenderbim/bim/module/style/ui.py b/src/blenderbim/blenderbim/bim/module/style/ui.py index 6b7d57efc9..404bf3e26c 100644 --- a/src/blenderbim/blenderbim/bim/module/style/ui.py +++ b/src/blenderbim/blenderbim/bim/module/style/ui.py @@ -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")