gpv3 update info to name property

master
pullusb 2024-11-11 15:56:43 +01:00
parent eae69b6f75
commit 3ece64e517
11 changed files with 59 additions and 59 deletions

View File

@ -9,7 +9,7 @@ from bpy.props import (FloatProperty,
## copied from OP_key_duplicate_send ## copied from OP_key_duplicate_send
def get_layer_list(self, context): def get_layer_list(self, context):
'''return (identifier, name, description) of enum content''' '''return (identifier, name, description) of enum content'''
return [(l.info, l.info, '') for l in context.object.data.layers if l != context.object.data.layers.active] return [(l.name, l.name, '') for l in context.object.data.layers if l != context.object.data.layers.active]
class GP_OT_create_empty_frames(bpy.types.Operator): class GP_OT_create_empty_frames(bpy.types.Operator):
bl_idname = "gp.create_empty_frames" bl_idname = "gp.create_empty_frames"
@ -113,7 +113,7 @@ class GP_OT_create_empty_frames(bpy.types.Operator):
if not self.layers_enum: if not self.layers_enum:
self.report({'ERROR'}, f"No chosen layers, aborted") self.report({'ERROR'}, f"No chosen layers, aborted")
return {'CANCELLED'} return {'CANCELLED'}
tgt_layers = [l for l in gpl if l.info == self.layers_enum] tgt_layers = [l for l in gpl if l.name == self.layers_enum]
elif self.targeted_layers == 'NUMBER': elif self.targeted_layers == 'NUMBER':
if self.number == 0: if self.number == 0:
@ -168,7 +168,7 @@ class GP_OT_create_empty_frames(bpy.types.Operator):
gpl.update() gpl.update()
if fct: if fct:
self.report({'INFO'}, f"{fct} frame created on layer {gpl.active.info}") self.report({'INFO'}, f"{fct} frame created on layer {gpl.active.name}")
else: else:
self.report({'WARNING'}, f"No frames to create !") self.report({'WARNING'}, f"No frames to create !")

View File

@ -277,12 +277,12 @@ class GPSTK_OT_extend_lines(bpy.types.Operator):
elif self.layer_tgt == 'ALL_VISIBLE': elif self.layer_tgt == 'ALL_VISIBLE':
lays = [l for l in ob.data.layers if not l.hide] lays = [l for l in ob.data.layers if not l.hide]
else: else:
lays = [l for l in ob.data.layers if not any(x in l.info for x in ('spot', 'colo'))] lays = [l for l in ob.data.layers if not any(x in l.name for x in ('spot', 'colo'))]
fct = 0 fct = 0
for l in lays: for l in lays:
if not l.active_frame: if not l.active_frame:
print(f'{l.info} has no active frame') print(f'{l.name} has no active frame')
continue continue
fct += extend_all_strokes_tips(ob, l.active_frame, length = self.length, selected = self.selected) fct += extend_all_strokes_tips(ob, l.active_frame, length = self.length, selected = self.selected)
@ -338,12 +338,12 @@ class GPSTK_OT_change_closeline_length(bpy.types.Operator):
elif self.layer_tgt == 'ALL_VISIBLE': elif self.layer_tgt == 'ALL_VISIBLE':
lays = [l for l in ob.data.layers if not l.hide] lays = [l for l in ob.data.layers if not l.hide]
else: else:
lays = [l for l in ob.data.layers if not any(x in l.info for x in ('spot', 'colo'))] lays = [l for l in ob.data.layers if not any(x in l.name for x in ('spot', 'colo'))]
fct = 0 fct = 0
for l in lays: for l in lays:
if not l.active_frame: if not l.active_frame:
print(f'{l.info} has no active frame') print(f'{l.name} has no active frame')
continue continue
fct += change_extension_length(ob, [s for s in l.active_frame.strokes], length = self.length, selected = self.selected) fct += change_extension_length(ob, [s for s in l.active_frame.strokes], length = self.length, selected = self.selected)

View File

@ -575,11 +575,11 @@ class GPCLIP_OT_copy_multi_strokes(bpy.types.Operator):
frame_dic[f.frame_number] = strokelist frame_dic[f.frame_number] = strokelist
layerdic[l.info] = frame_dic layerdic[l.name] = frame_dic
else: # bake position: copy frame where object as moved even if frame is unchanged else: # bake position: copy frame where object as moved even if frame is unchanged
for l in layerpool: for l in layerpool:
print('dump layer:', l.info) print('dump layer:', l.name)
if not l.frames: if not l.frames:
continue# skip empty layers continue# skip empty layers
@ -613,7 +613,7 @@ class GPCLIP_OT_copy_multi_strokes(bpy.types.Operator):
frame_dic[i] = strokelist frame_dic[i] = strokelist
prevmat = curmat prevmat = curmat
layerdic[l.info] = frame_dic layerdic[l.name] = frame_dic
## All to clipboard manager ## All to clipboard manager
bpy.context.window_manager.clipboard = json.dumps(layerdic) bpy.context.window_manager.clipboard = json.dumps(layerdic)

View File

@ -202,7 +202,7 @@ class GPTB_OT_file_checker(bpy.types.Operator):
## check if GP modifier have broken layer targets ## check if GP modifier have broken layer targets
if fix.list_broken_mod_targets: if fix.list_broken_mod_targets:
for o in [o for o in bpy.context.scene.objects if o.type == 'GREASEPENCIL']: for o in [o for o in bpy.context.scene.objects if o.type == 'GREASEPENCIL']:
lay_name_list = [l.info for l in o.data.layers] lay_name_list = [l.name for l in o.data.layers]
for m in o.grease_pencil_modifiers: for m in o.grease_pencil_modifiers:
if not hasattr(m, 'layer'): if not hasattr(m, 'layer'):
continue continue

View File

@ -32,7 +32,7 @@ def batch_flat_reproject(obj, proj_type='VIEW', all_strokes=True, restore_frame=
fnum = len(l.frames) fnum = len(l.frames)
zf = len(str(fnum)) zf = len(str(fnum))
for j, f in enumerate(reversed(l.frames)): # whynot... for j, f in enumerate(reversed(l.frames)): # whynot...
print(f'{obj.name} : {i+1}/{laynum} : {l.info} : {str(j+1).zfill(zf)}/{fnum}{" "*30}', end='\r') print(f'{obj.name} : {i+1}/{laynum} : {l.name} : {str(j+1).zfill(zf)}/{fnum}{" "*30}', end='\r')
scn.frame_set(f.frame_number) # more chance to update the matrix scn.frame_set(f.frame_number) # more chance to update the matrix
bpy.context.view_layer.update() # update the matrix ? bpy.context.view_layer.update() # update the matrix ?
bpy.context.scene.camera.location = bpy.context.scene.camera.location bpy.context.scene.camera.location = bpy.context.scene.camera.location

View File

@ -8,7 +8,7 @@ def get_layer_list(self, context):
return [('None', 'None','None')] return [('None', 'None','None')]
if not context.object: if not context.object:
return [('None', 'None','None')] return [('None', 'None','None')]
return [(l.info, l.info, '') for l in context.object.data.layers if l != context.object.data.layers.active] return [(l.name, l.name, '') for l in context.object.data.layers if l != context.object.data.layers.active]
# try: # try:
# except: # except:
# return [("", "", "")] # return [("", "", "")]

View File

@ -30,7 +30,7 @@ def layer_name_build(layer, prefix='', desc='', suffix=''):
prefs = get_addon_prefs() prefs = get_addon_prefs()
sep = prefs.separator sep = prefs.separator
name = old = layer.info name = old = layer.name
pattern = PATTERN.replace('_', sep) # set separator pattern = PATTERN.replace('_', sep) # set separator
@ -69,7 +69,7 @@ def layer_name_build(layer, prefix='', desc='', suffix=''):
# check if name is available without the increment ending # check if name is available without the increment ending
new = f'{grp}{tag}{name}{sfix}' new = f'{grp}{tag}{name}{sfix}'
layer.info = new layer.name = new
## update name in modifier targets ## update name in modifier targets
if old != new: if old != new:
@ -93,7 +93,7 @@ def layer_name_build(layer, prefix='', prefix2='', desc='', suffix=''):
prefs = get_addon_prefs() prefs = get_addon_prefs()
sep = prefs.separator sep = prefs.separator
name = layer.info name = layer.name
pattern = pattern.replace('_', sep) # set separator pattern = pattern.replace('_', sep) # set separator
@ -122,7 +122,7 @@ def layer_name_build(layer, prefix='', prefix2='', desc='', suffix=''):
p4 = sep + suffix.upper().strip() p4 = sep + suffix.upper().strip()
new = f'{p1}{p2}{p3}{p4}' new = f'{p1}{p2}{p3}{p4}'
layer.info = new layer.name = new
""" """
## multi-prefix solution (Caps letters) ## multi-prefix solution (Caps letters)
@ -172,14 +172,14 @@ class GPTB_OT_layer_name_build(Operator):
def grp_toggle(l, mode='TOGGLE'): def grp_toggle(l, mode='TOGGLE'):
'''take mode in (TOGGLE, GROUP, UNGROUP) ''' '''take mode in (TOGGLE, GROUP, UNGROUP) '''
grp_item_id = ' - ' grp_item_id = ' - '
res = re.search(r'^(\s{1,3}-\s{0,3})(.*)', l.info) res = re.search(r'^(\s{1,3}-\s{0,3})(.*)', l.name)
if not res and mode in ('TOGGLE', 'GROUP'): if not res and mode in ('TOGGLE', 'GROUP'):
# No gpr : add group prefix after stripping all space and dash # No gpr : add group prefix after stripping all space and dash
l.info = grp_item_id + l.info.lstrip(' -') l.name = grp_item_id + l.name.lstrip(' -')
elif res and mode in ('TOGGLE', 'UNGROUP'): elif res and mode in ('TOGGLE', 'UNGROUP'):
# found : delete group prefix # found : delete group prefix
l.info = res.group(2) l.name = res.group(2)
class GPTB_OT_layer_group_toggle(Operator): class GPTB_OT_layer_group_toggle(Operator):
@ -220,18 +220,18 @@ class GPTB_OT_layer_new_group(Operator):
self.report({'ERROR'}, 'no layer active') self.report({'ERROR'}, 'no layer active')
return {"CANCELLED"} return {"CANCELLED"}
res = re.search(PATTERN, act.info) res = re.search(PATTERN, act.name)
if not res: if not res:
self.report({'ERROR'}, 'Could not create a group name, create a layer manually') self.report({'ERROR'}, 'Could not create a group name, create a layer manually')
return {"CANCELLED"} return {"CANCELLED"}
name = res.group('name').strip(' -') name = res.group('name').strip(' -')
if not name: if not name:
self.report({'ERROR'}, f'No name found in {act.info}') self.report({'ERROR'}, f'No name found in {act.name}')
return {"CANCELLED"} return {"CANCELLED"}
if name in [l.info.strip(' -') for l in gpl]: if name in [l.name.strip(' -') for l in gpl]:
self.report({'WARNING'}, f'Name already exists: {act.info}') self.report({'WARNING'}, f'Name already exists: {act.name}')
return {"FINISHED"} return {"FINISHED"}
grp_toggle(act, mode='GROUP') grp_toggle(act, mode='GROUP')
@ -272,7 +272,7 @@ def build_layers_targets_from_dopesheet(context):
# apply search filter # apply search filter
if dopeset.filter_text: if dopeset.filter_text:
layer_pool = [l for l in layer_pool if (dopeset.filter_text.lower() in l.info.lower()) ^ dopeset.use_filter_invert] layer_pool = [l for l in layer_pool if (dopeset.filter_text.lower() in l.name.lower()) ^ dopeset.use_filter_invert]
return layer_pool return layer_pool
@ -330,35 +330,35 @@ class GPTB_OT_select_set_same_prefix(Operator):
self.report({'ERROR'}, 'No active layer to base action') self.report({'ERROR'}, 'No active layer to base action')
return {"CANCELLED"} return {"CANCELLED"}
print(f'Select/Set ref layer: {gp.name} > {gp.layers.active.info}') print(f'Select/Set ref layer: {gp.name} > {gp.layers.active.name}')
res = re.search(PATTERN, act.info) res = re.search(PATTERN, act.name)
if not res: if not res:
self.report({'ERROR'}, f'Error scanning {act.info}') self.report({'ERROR'}, f'Error scanning {act.name}')
return {"CANCELLED"} return {"CANCELLED"}
namespace = res.group('tag') namespace = res.group('tag')
if not namespace: if not namespace:
self.report({'WARNING'}, f'No prefix detected in {act.info} with separator {sep}') self.report({'WARNING'}, f'No prefix detected in {act.name} with separator {sep}')
return {"CANCELLED"} return {"CANCELLED"}
if self.mode == 'SELECT': if self.mode == 'SELECT':
## with split ## with split
# namespace = act.info.split(sep,1)[0] # namespace = act.name.split(sep,1)[0]
# namespace_bool_list = [l.info.split(sep,1)[0] == namespace for l in gpl] # namespace_bool_list = [l.name.split(sep,1)[0] == namespace for l in gpl]
## with reg # only active ## with reg # only active
# namespace_bool_list = [l.info.split(sep,1)[0] + sep == namespace for l in gpl] # namespace_bool_list = [l.name.split(sep,1)[0] + sep == namespace for l in gpl]
# gpl.foreach_set('select', namespace_bool_list) # gpl.foreach_set('select', namespace_bool_list)
## don't work Need Foreach set per gp ## don't work Need Foreach set per gp
# for l in pool: # for l in pool:
# l.select = l.info.split(sep,1)[0] + sep == namespace # l.select = l.name.split(sep,1)[0] + sep == namespace
for gp, layers in gp_dic.items(): for gp, layers in gp_dic.items():
# check namespace + restrict selection to visible layers according to filters # check namespace + restrict selection to visible layers according to filters
# TODO : Should use the regex pattern to detect and compare r.group('tag') # TODO : Should use the regex pattern to detect and compare r.group('tag')
namespace_bool_list = [(l in layers) and (l.info.split(sep,1)[0] + sep == namespace) for l in gp.layers] namespace_bool_list = [(l in layers) and (l.name.split(sep,1)[0] + sep == namespace) for l in gp.layers]
gp.layers.foreach_set('select', namespace_bool_list) gp.layers.foreach_set('select', namespace_bool_list)
elif self.mode == 'SET': elif self.mode == 'SET':
@ -415,7 +415,7 @@ class GPTB_OT_select_set_same_color(Operator):
self.report({'ERROR'}, 'No active layer to base action') self.report({'ERROR'}, 'No active layer to base action')
return {"CANCELLED"} return {"CANCELLED"}
print(f'Select/Set ref layer: {gp.name} > {gp.layers.active.info}') print(f'Select/Set ref layer: {gp.name} > {gp.layers.active.name}')
color = act.channel_color color = act.channel_color
if self.mode == 'SELECT': if self.mode == 'SELECT':
## NEED FOREACH TO APPLY SELECT ## NEED FOREACH TO APPLY SELECT
@ -426,7 +426,7 @@ class GPTB_OT_select_set_same_color(Operator):
# On multiple objects -- don't work, need foreach # On multiple objects -- don't work, need foreach
# for l in pool: # for l in pool:
# print(l.id_data.name, l.info, l.channel_color == act.channel_color) # print(l.id_data.name, l.name, l.channel_color == act.channel_color)
# l.select = l.channel_color == act.channel_color # l.select = l.channel_color == act.channel_color
""" """
@ -463,38 +463,38 @@ def replace_layer_name(target, replacement, selected_only=True, prefix_only=True
gpl = bpy.context.object.data.layers gpl = bpy.context.object.data.layers
if selected_only: if selected_only:
lays = [l for l in gpl if l.select] # exclude : l.info != 'background' lays = [l for l in gpl if l.select] # exclude : l.name != 'background'
else: else:
lays = [l for l in gpl] # exclude : if l.info != 'background' lays = [l for l in gpl] # exclude : if l.name != 'background'
ct = 0 ct = 0
for l in lays: for l in lays:
old = l.info old = l.name
if regex: if regex:
new = re.sub(target, replacement, l.info) new = re.sub(target, replacement, l.name)
if old != new: if old != new:
l.info = new l.name = new
print('rename:', old, '-->', new) print('rename:', old, '-->', new)
ct += 1 ct += 1
continue continue
if prefix_only: if prefix_only:
if not sep in l.info: if not sep in l.name:
# only if separator exists # only if separator exists
continue continue
splited = l.info.split(sep) splited = l.name.split(sep)
prefix = splited[0] prefix = splited[0]
new_prefix = prefix.replace(target, replacement) new_prefix = prefix.replace(target, replacement)
if prefix != new_prefix: if prefix != new_prefix:
splited[0] = new_prefix splited[0] = new_prefix
l.info = sep.join(splited) l.name = sep.join(splited)
print('rename:', old, '-->', l.info) print('rename:', old, '-->', l.name)
ct += 1 ct += 1
else: else:
new = l.info.replace(target, replacement) new = l.name.replace(target, replacement)
if old != new: if old != new:
l.info = new l.name = new
print('rename:', old, '-->', new) print('rename:', old, '-->', new)
ct += 1 ct += 1
return ct return ct
@ -663,7 +663,7 @@ def obj_layer_name_callback():
for l in ob.data.layers: for l in ob.data.layers:
l.select = l == ob.data.layers.active l.select = l == ob.data.layers.active
res = re.search(PATTERN, ob.data.layers.active.info.strip()) res = re.search(PATTERN, ob.data.layers.active.name.strip())
if not res: if not res:
return return
if not res.group('name'): if not res.group('name'):

View File

@ -47,7 +47,7 @@ class GP_OT_pick_closest_layer(Operator):
def draw(self, context): def draw(self, context):
layout = self.layout layout = self.layout
if context.object.data.layers.active: if context.object.data.layers.active:
layout.label(text=f'Layer: {context.object.data.layers.active.info}') layout.label(text=f'Layer: {context.object.data.layers.active.name}')
layout.prop(self, 'stroke_filter') layout.prop(self, 'stroke_filter')
def modal(self, context, event): def modal(self, context, event):
@ -117,7 +117,7 @@ class GP_OT_pick_closest_layer(Operator):
## debug show trigger time ## debug show trigger time
# print(f'Trigger time {time() - self.t0:.3f}') # print(f'Trigger time {time() - self.t0:.3f}')
# print(f'Search time {time() - t1:.3f}') # print(f'Search time {time() - t1:.3f}')
self.report({'INFO'}, f'Layer: {self.ob.data.layers.active.info}') self.report({'INFO'}, f'Layer: {self.ob.data.layers.active.name}')
return {'FINISHED'} return {'FINISHED'}

View File

@ -11,7 +11,7 @@ from . import utils
# return [('None', 'None','None')] # return [('None', 'None','None')]
# if not context.object: # if not context.object:
# return [('None', 'None','None')] # return [('None', 'None','None')]
# return [(l.info, l.info, '') for l in context.object.data.layers] # if l != context.object.data.layers.active # return [(l.name, l.name, '') for l in context.object.data.layers] # if l != context.object.data.layers.active
## in Class ## in Class
# bl_property = "layers_enum" # bl_property = "layers_enum"
@ -72,8 +72,8 @@ class GPTB_OT_move_material_to_layer(Operator) :
icon = 'GREASEPENCIL' if l == context.object.data.layers.active else 'BLANK1' icon = 'GREASEPENCIL' if l == context.object.data.layers.active else 'BLANK1'
row = col.row() row = col.row()
row.alignment = 'LEFT' row.alignment = 'LEFT'
op = col.operator('gp.move_material_to_layer', text=l.info, icon=icon, emboss=False) op = col.operator('gp.move_material_to_layer', text=l.name, icon=icon, emboss=False)
op.layer_name = l.info op.layer_name = l.name
op.copy = self.copy op.copy = self.copy
def execute(self, context): def execute(self, context):

View File

@ -74,7 +74,7 @@ class GPT_OT_auto_tint_gp_layers(bpy.types.Operator):
# namespace_order # namespace_order
namespaces=[] namespaces=[]
for l in gpl: for l in gpl:
ns= l.info.lower().split(separator, 1)[0] ns= l.name.lower().split(separator, 1)[0]
if ns not in namespaces: if ns not in namespaces:
namespaces.append(ns) namespaces.append(ns)
@ -88,14 +88,14 @@ class GPT_OT_auto_tint_gp_layers(bpy.types.Operator):
### step from 0.1 to 0.9 ### step from 0.1 to 0.9
for i, l in enumerate(gpl): for i, l in enumerate(gpl):
if l.info.lower() not in ('background',): if l.name.lower() not in ('background',):
print() print()
print('>', l.info) print('>', l.name)
ns= l.info.lower().split(separator, 1)[0]#get namespace from separator ns= l.name.lower().split(separator, 1)[0]#get namespace from separator
print("namespace", ns)#Dbg print("namespace", ns)#Dbg
if context.scene.gptoolprops.autotint_namespace: if context.scene.gptoolprops.autotint_namespace:
h = get_hue_by_name(ns, hue_offset)#l.info == individuels h = get_hue_by_name(ns, hue_offset)#l.name == individuels
else: else:
h = translate_range((i + hue_offset/100)%layer_ct, 0, layer_ct, 0.1, 0.9) h = translate_range((i + hue_offset/100)%layer_ct, 0, layer_ct, 0.1, 0.9)

View File

@ -26,7 +26,7 @@ def update_layer_name(self, context):
if not context.object.data.layers.active: if not context.object.data.layers.active:
return return
layer_name_build(context.object.data.layers.active, desc=self.layer_name) layer_name_build(context.object.data.layers.active, desc=self.layer_name)
# context.object.data.layers.active.info = self.layer_name # context.object.data.layers.active.name = self.layer_name
class GP_PG_FixSettings(PropertyGroup): class GP_PG_FixSettings(PropertyGroup):