[Bf-extensions-cvs] [fd6407c2] master: GPencil Tools: Fix box-deform with multi-user data
Pullusb
noreply at git.blender.org
Wed Apr 14 23:31:07 CEST 2021
Commit: fd6407c23f349aee616ca27d32b7a14770f2cc06
Author: Pullusb
Date: Wed Apr 14 23:31:00 2021 +0200
Branches: master
https://developer.blender.org/rBAfd6407c23f349aee616ca27d32b7a14770f2cc06
GPencil Tools: Fix box-deform with multi-user data
Box deforming a grease pencil that has multiple instances now works without throwing an error.
===================================================================
M greasepencil_tools/__init__.py
M greasepencil_tools/box_deform.py
===================================================================
diff --git a/greasepencil_tools/__init__.py b/greasepencil_tools/__init__.py
index 66a9f611..494354d5 100644
--- a/greasepencil_tools/__init__.py
+++ b/greasepencil_tools/__init__.py
@@ -21,7 +21,7 @@ bl_info = {
"name": "Grease Pencil Tools",
"description": "Extra tools for Grease Pencil",
"author": "Samuel Bernou, Antonio Vazquez, Daniel Martinez Lara, Matias Mendiola",
-"version": (1, 4, 2),
+"version": (1, 4, 3),
"blender": (2, 91, 0),
"location": "Sidebar > Grease Pencil > Grease Pencil Tools",
"warning": "",
diff --git a/greasepencil_tools/box_deform.py b/greasepencil_tools/box_deform.py
index 92f171f6..0ac08987 100644
--- a/greasepencil_tools/box_deform.py
+++ b/greasepencil_tools/box_deform.py
@@ -262,8 +262,22 @@ def delete_cage(cage):
def apply_cage(gp_obj, cage):
mod = gp_obj.grease_pencil_modifiers.get('tmp_lattice')
+ multi_user = None
if mod:
+ if gp_obj.data.users > 1:
+ old = gp_obj.data
+ multi_user = old.name
+ other_user = [o for o in bpy.data.objects if o is not gp_obj and o.data is old]
+ gp_obj.data = gp_obj.data.copy()
+
bpy.ops.object.gpencil_modifier_apply(apply_as='DATA', modifier=mod.name)
+
+ if multi_user:
+ for o in other_user: # relink
+ o.data = gp_obj.data
+ bpy.data.grease_pencils.remove(old)
+ gp_obj.data.name = multi_user
+
else:
print('tmp_lattice modifier not found to apply...')
More information about the Bf-extensions-cvs
mailing list