From 550f9909ec62aef23a635e8d512fb05868268694 Mon Sep 17 00:00:00 2001 From: "s.ivanov" Date: Wed, 13 May 2026 16:21:12 +0200 Subject: [PATCH] Update baker.py fix(baker): ensure engine property exists on class for restored bakers - Move engine EnumProperty definition before the index check in initialize() with a hasattr guard, so bakers loaded from saved files have the attribute - Use getattr(self, 'engine', None) in draw() and Normals.draw_properties() as fallback during UI rendering before initialization completes --- baker.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/baker.py b/baker.py index 8972466..8e25b34 100644 --- a/baker.py +++ b/baker.py @@ -33,18 +33,19 @@ class Baker(PropertyGroup): def initialize(self): """Initialize baker instance after creation in PropertyCollection.""" + # NOTE: engine property must exist on class for all instances + if not hasattr(self.__class__, 'engine'): + self.__class__.engine = EnumProperty( + name='Render Engine', + items=self.__class__.SUPPORTED_ENGINES, + update=self.__class__.apply_render_settings + ) + if self.index != -1: return self.set_available_index() self.node_setup() - # NOTE: Unique due to dynamic items/enum - self.__class__.engine = EnumProperty( - name='Render Engine', - items=self.__class__.SUPPORTED_ENGINES, - update=self.__class__.apply_render_settings - ) - self.node_input = None self.node_output = None if len(self.REQUIRED_SOCKETS) > 0 or self.ID == 'custom': @@ -160,9 +161,10 @@ def draw(self, context: Context, layout: UILayout): col_set.prop(self, 'reimport') col_set.prop(self, 'disable_filtering') prop = 'samples' - if self.engine == 'blender_workbench': + engine = getattr(self, 'engine', None) + if engine == 'blender_workbench': prop = 'samples_workbench' - elif self.engine == 'cycles': + elif engine == 'cycles': prop = 'samples_cycles' col_set.prop(self, prop, text='Samples') col_set.prop(self, 'contrast') @@ -345,7 +347,7 @@ def draw_properties(self, context: Context, layout: UILayout): col = layout.column() col.prop(self, 'flip_y') if context.scene.gd.engine == 'grabdoc': - if self.engine == 'cycles': + if getattr(self, 'engine', None) == 'cycles': col.prop(self, 'bevel_weight') def update_flip_y(self, _context: Context):