From a21bf4d7f4e02405ca3b16746a3af4759fa6889e Mon Sep 17 00:00:00 2001 From: chsh2 <110356534+chsh2@users.noreply.github.com> Date: Tue, 5 Dec 2023 23:32:54 -0800 Subject: [PATCH] Blender 4.0 API change --- operators/operator_io_assets.py | 4 ++-- ui_viewport_tools.py | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/operators/operator_io_assets.py b/operators/operator_io_assets.py index 3d46ddf..92719ce 100644 --- a/operators/operator_io_assets.py +++ b/operators/operator_io_assets.py @@ -258,8 +258,8 @@ def execute(self, context): # Create an icon by scaling the brush texture down icon_obj = img_obj.copy() - icon_obj.name = "icon_"+new_brush.name - icon_filepath = os.path.join(icon_dir, new_brush.name+'.png') + icon_obj.name = f"icon_{f.name.split('.')[0]}_{i}" + icon_filepath = os.path.join(icon_dir, icon_obj.name+'.png') icon_obj.filepath = icon_filepath icon_obj.scale(256,256) icon_obj.save() diff --git a/ui_viewport_tools.py b/ui_viewport_tools.py index 5deca47..aa3c8a2 100644 --- a/ui_viewport_tools.py +++ b/ui_viewport_tools.py @@ -229,7 +229,12 @@ def draw_callback_px(self, op, context): blf.color(self.font_id, 0, 0, 0, 1) blf.enable(self.font_id, blf.SHADOW) blf.shadow(self.font_id, 3, 0.8, 0.8, 0.8, 0.95) - blf.size(self.font_id, 36 if stroke.select else 24, 72) + # The third parameter became optional since Blender 3.4, + # and was deprecated in Blender 4.0 + if bpy.app.version > (3, 6, 0): + blf.size(self.font_id, 36 if stroke.select else 24) + else: + blf.size(self.font_id, 36 if stroke.select else 24, 72) blf.position(self.font_id, view_co[0], view_co[1], 0) blf.draw(self.font_id, str(i))