Layer name manager fix modifier targets

1.9.4

- feat: renaming using the name_manager take care of changing layer target values in GP modifiers
gpv2
Pullusb 2022-01-25 15:13:08 +01:00
parent 1145b73b58
commit 651f9e7747
3 changed files with 22 additions and 3 deletions

View File

@ -1,5 +1,9 @@
# Changelog
1.9.4
- feat: renaming using the name_manager take care of changing layer target values in GP modifiers
1.9.3
- feat: Add an update button at bottom of preferences if addon is a cloned repository

View File

@ -23,12 +23,14 @@ PATTERN = r'^(?P<grp>-\s)?(?P<tag>[A-Z]{2}_)?(?P<name>.*?)(?P<sfix>_[A-Z]{2})?(?
def layer_name_build(layer, prefix='', desc='', suffix=''):
'''GET a layer and argumen to build and assign name'''
'''GET a layer and argument to build and assign name
return new name
'''
prefs = get_addon_prefs()
sep = prefs.separator
name = layer.info
name = old = layer.info
pattern = PATTERN.replace('_', sep) # set separator
@ -68,6 +70,19 @@ def layer_name_build(layer, prefix='', desc='', suffix=''):
new = f'{grp}{tag}{name}{sfix}'
layer.info = new
## update name in modifier targets
if old != new:
# find objects using this GP datablock
for ob_user in [o for o in bpy.data.objects if o.data == layer.id_data]: # bpy.context.scene.objects
# maybe a more elegant way exists to find all objects users ?
# update Gpencil modifier targets
for mod in ob_user.grease_pencil_modifiers:
if not hasattr(mod, 'layer'):
continue
if mod.layer == old:
mod.layer = new
"""
def layer_name_build(layer, prefix='', prefix2='', desc='', suffix=''):

View File

@ -15,7 +15,7 @@ bl_info = {
"name": "GP toolbox",
"description": "Tool set for Grease Pencil in animation production",
"author": "Samuel Bernou, Christophe Seux",
"version": (1, 9, 3),
"version": (1, 9, 4),
"blender": (2, 91, 0),
"location": "Sidebar (N menu) > Gpencil > Toolbox / Gpencil properties",
"warning": "",