diff options
author | Pullusb <bernou.samuel@gmail.com> | 2021-04-15 00:31:00 +0300 |
---|---|---|
committer | Pullusb <bernou.samuel@gmail.com> | 2021-04-15 00:31:00 +0300 |
commit | fd6407c23f349aee616ca27d32b7a14770f2cc06 (patch) | |
tree | 18f1f8c582e3f7c2ee5616da0d31ff6cd892c10f | |
parent | 1dbdb95ed93a8b96d12e42e17249f6e2cdd24619 (diff) |
GPencil Tools: Fix box-deform with multi-user data
Box deforming a grease pencil that has multiple instances now works without throwing an error.
-rw-r--r-- | greasepencil_tools/__init__.py | 2 | ||||
-rw-r--r-- | greasepencil_tools/box_deform.py | 14 |
2 files changed, 15 insertions, 1 deletions
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...') |