@@ -744,7 +744,7 @@ def execute(self, context):
744744 if self .ifc_class == "IfcSurfaceStyleLighting" :
745745
746746 def callback (attribute_name : str , _ : object , data : dict [str , Any ]) -> None :
747- assert attributes
747+ assert attributes is not None
748748 color = attributes .add ()
749749 assert isinstance (color , ColourRgb )
750750 color .name = attribute_name
@@ -782,34 +782,40 @@ class EditSurfaceStyle(bpy.types.Operator, tool.Ifc.Operator):
782782 def _execute (self , context ):
783783 self .props = tool .Style .get_style_props ()
784784 self .style = tool .Ifc .get ().by_id (self .props .is_editing_style )
785+ prev_update_graph = self .props .update_graph
786+ self .props ["update_graph" ] = False
785787
786- style_elements = tool .Style .get_style_elements (self .style )
787- # NOTE: currently this operator is used to edit existing (and only existing) IfcSurfaceStyles
788- # or new or existing IfcSurfaceStyle components (shading, etc)
789- # which is kind of confusing.
790- if self .props .is_editing_class == "IfcSurfaceStyle" :
791- self .surface_style = self .style
792- else :
793- self .surface_style = style_elements .get (self .props .is_editing_class , None )
794- self .shading_style = style_elements .get ("IfcSurfaceStyleShading" , None )
795- self .rendering_style = style_elements .get ("IfcSurfaceStyleRendering" , None )
796- self .texture_style = style_elements .get ("IfcSurfaceStyleWithTextures" , None )
788+ try :
789+ style_elements = tool .Style .get_style_elements (self .style )
797790
798- if self .surface_style :
799- result = self .edit_existing_style ()
800- else :
801- result = self .add_new_style ()
791+ # NOTE: currently this operator is used to edit existing (and only existing) IfcSurfaceStyles
792+ # or new or existing IfcSurfaceStyle components (shading, etc)
793+ # which is kind of confusing.
794+ if self .props .is_editing_class == "IfcSurfaceStyle" :
795+ self .surface_style = self .style
796+ else :
797+ self .surface_style = style_elements .get (self .props .is_editing_class , None )
798+ self .shading_style = style_elements .get ("IfcSurfaceStyleShading" , None )
799+ self .rendering_style = style_elements .get ("IfcSurfaceStyleRendering" , None )
800+ self .texture_style = style_elements .get ("IfcSurfaceStyleWithTextures" , None )
802801
803- if result :
804- return result
802+ if self .surface_style :
803+ result = self .edit_existing_style ()
804+ else :
805+ result = self .add_new_style ()
805806
806- tool . Style . disable_editing ()
807- core . load_styles ( tool . Style , style_type = self . props . style_type )
807+ if result :
808+ return result
808809
809- # restore selected style type
810- material = tool .Ifc .get_object (self .style )
811- msprops = tool .Style .get_material_style_props (material )
812- msprops .active_style_type = msprops .active_style_type
810+ tool .Style .disable_editing ()
811+ core .load_styles (tool .Style , style_type = self .props .style_type )
812+
813+ # restore selected style type
814+ material = tool .Ifc .get_object (self .style )
815+ msprops = tool .Style .get_material_style_props (material )
816+ msprops .active_style_type = msprops .active_style_type
817+ finally :
818+ self .props ["update_graph" ] = prev_update_graph
813819
814820 def edit_existing_style (self ) -> None :
815821 ifc_file = tool .Ifc .get ()
@@ -1231,4 +1237,5 @@ def _execute(self, context):
12311237 surface_style = tool .Style .get_style_elements (style )[props .is_editing_class ]
12321238 ifcopenshell .api .style .remove_surface_style (ifc_file , surface_style )
12331239 core .disable_editing_style (tool .Style )
1240+ core .load_styles (tool .Style , style_type = props .style_type )
12341241 return {"FINISHED" }
0 commit comments