From 9f2df7fb9d4b0bc77783c24e4c95d9f487021ba6 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Fri, 3 May 2024 17:55:30 +0500 Subject: [PATCH] preview external shading style as material is selected from other .blend file previously it required to save external style attributes to preview the changes, now it's couple clicks saved if you want to preview different blender materials for your styles --- .../blenderbim/bim/module/style/operator.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/blenderbim/blenderbim/bim/module/style/operator.py b/src/blenderbim/blenderbim/bim/module/style/operator.py index 600554ae93..e59e60da74 100644 --- a/src/blenderbim/blenderbim/bim/module/style/operator.py +++ b/src/blenderbim/blenderbim/bim/module/style/operator.py @@ -316,6 +316,9 @@ class BrowseExternalStyle(bpy.types.Operator): attributes["Location"].string_value = filepath attributes["Identification"].string_value = f"{self.data_block_type}/{self.data_block}" attributes["Name"].string_value = self.data_block + + style = tool.Ifc.get().by_id(self.active_surface_style_id) + bpy.ops.bim.activate_external_style(material_name=tool.Ifc.get_object(style).name) return {"FINISHED"} @@ -331,9 +334,18 @@ class ActivateExternalStyle(bpy.types.Operator, tool.Ifc.Operator): material = context.active_object.active_material else: material = bpy.data.materials[self.material_name] - external_style = tool.Style.get_style_elements(material)["IfcExternallyDefinedSurfaceStyle"] - data_block_type, data_block = external_style.Identification.split("/") - style_path = Path(tool.Ifc.resolve_uri(external_style.Location)) + + props = context.scene.BIMStylesProperties + if props.is_editing: + location = props.external_style_attributes["Location"].string_value + identification = props.external_style_attributes["Identification"].string_value + else: + external_style = tool.Style.get_style_elements(material)["IfcExternallyDefinedSurfaceStyle"] + location = external_style.Location + identification = external_style.Identification + + data_block_type, data_block = identification.split("/") + style_path = Path(tool.Ifc.resolve_uri(location)) if style_path.suffix != ".blend": self.report(