Layer name manager fix modifier targets
1.9.4 - feat: renaming using the name_manager take care of changing layer target values in GP modifiersgpv2
parent
1145b73b58
commit
651f9e7747
|
@ -1,5 +1,9 @@
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
1.9.4
|
||||||
|
|
||||||
|
- feat: renaming using the name_manager take care of changing layer target values in GP modifiers
|
||||||
|
|
||||||
1.9.3
|
1.9.3
|
||||||
|
|
||||||
- feat: Add an update button at bottom of preferences if addon is a cloned repository
|
- feat: Add an update button at bottom of preferences if addon is a cloned repository
|
||||||
|
|
|
@ -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=''):
|
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()
|
prefs = get_addon_prefs()
|
||||||
sep = prefs.separator
|
sep = prefs.separator
|
||||||
name = layer.info
|
name = old = layer.info
|
||||||
|
|
||||||
pattern = PATTERN.replace('_', sep) # set separator
|
pattern = PATTERN.replace('_', sep) # set separator
|
||||||
|
|
||||||
|
@ -69,6 +71,19 @@ def layer_name_build(layer, prefix='', desc='', suffix=''):
|
||||||
|
|
||||||
layer.info = new
|
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=''):
|
def layer_name_build(layer, prefix='', prefix2='', desc='', suffix=''):
|
||||||
'''GET a layer and infos to build name
|
'''GET a layer and infos to build name
|
||||||
|
|
|
@ -15,7 +15,7 @@ bl_info = {
|
||||||
"name": "GP toolbox",
|
"name": "GP toolbox",
|
||||||
"description": "Tool set for Grease Pencil in animation production",
|
"description": "Tool set for Grease Pencil in animation production",
|
||||||
"author": "Samuel Bernou, Christophe Seux",
|
"author": "Samuel Bernou, Christophe Seux",
|
||||||
"version": (1, 9, 3),
|
"version": (1, 9, 4),
|
||||||
"blender": (2, 91, 0),
|
"blender": (2, 91, 0),
|
||||||
"location": "Sidebar (N menu) > Gpencil > Toolbox / Gpencil properties",
|
"location": "Sidebar (N menu) > Gpencil > Toolbox / Gpencil properties",
|
||||||
"warning": "",
|
"warning": "",
|
||||||
|
|
Loading…
Reference in New Issue