gpv3 update info to name property
parent
eae69b6f75
commit
3ece64e517
|
@ -9,7 +9,7 @@ from bpy.props import (FloatProperty,
|
|||
## copied from OP_key_duplicate_send
|
||||
def get_layer_list(self, context):
|
||||
'''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):
|
||||
bl_idname = "gp.create_empty_frames"
|
||||
|
@ -113,7 +113,7 @@ class GP_OT_create_empty_frames(bpy.types.Operator):
|
|||
if not self.layers_enum:
|
||||
self.report({'ERROR'}, f"No chosen layers, aborted")
|
||||
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':
|
||||
if self.number == 0:
|
||||
|
@ -168,7 +168,7 @@ class GP_OT_create_empty_frames(bpy.types.Operator):
|
|||
|
||||
gpl.update()
|
||||
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:
|
||||
self.report({'WARNING'}, f"No frames to create !")
|
||||
|
||||
|
|
|
@ -277,12 +277,12 @@ class GPSTK_OT_extend_lines(bpy.types.Operator):
|
|||
elif self.layer_tgt == 'ALL_VISIBLE':
|
||||
lays = [l for l in ob.data.layers if not l.hide]
|
||||
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
|
||||
for l in lays:
|
||||
if not l.active_frame:
|
||||
print(f'{l.info} has no active frame')
|
||||
print(f'{l.name} has no active frame')
|
||||
continue
|
||||
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':
|
||||
lays = [l for l in ob.data.layers if not l.hide]
|
||||
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
|
||||
for l in lays:
|
||||
if not l.active_frame:
|
||||
print(f'{l.info} has no active frame')
|
||||
print(f'{l.name} has no active frame')
|
||||
continue
|
||||
fct += change_extension_length(ob, [s for s in l.active_frame.strokes], length = self.length, selected = self.selected)
|
||||
|
||||
|
|
|
@ -575,11 +575,11 @@ class GPCLIP_OT_copy_multi_strokes(bpy.types.Operator):
|
|||
|
||||
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
|
||||
for l in layerpool:
|
||||
print('dump layer:', l.info)
|
||||
print('dump layer:', l.name)
|
||||
if not l.frames:
|
||||
continue# skip empty layers
|
||||
|
||||
|
@ -613,7 +613,7 @@ class GPCLIP_OT_copy_multi_strokes(bpy.types.Operator):
|
|||
frame_dic[i] = strokelist
|
||||
|
||||
prevmat = curmat
|
||||
layerdic[l.info] = frame_dic
|
||||
layerdic[l.name] = frame_dic
|
||||
|
||||
## All to clipboard manager
|
||||
bpy.context.window_manager.clipboard = json.dumps(layerdic)
|
||||
|
|
|
@ -202,7 +202,7 @@ class GPTB_OT_file_checker(bpy.types.Operator):
|
|||
## check if GP modifier have broken layer targets
|
||||
if fix.list_broken_mod_targets:
|
||||
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:
|
||||
if not hasattr(m, 'layer'):
|
||||
continue
|
||||
|
|
|
@ -32,7 +32,7 @@ def batch_flat_reproject(obj, proj_type='VIEW', all_strokes=True, restore_frame=
|
|||
fnum = len(l.frames)
|
||||
zf = len(str(fnum))
|
||||
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
|
||||
bpy.context.view_layer.update() # update the matrix ?
|
||||
bpy.context.scene.camera.location = bpy.context.scene.camera.location
|
||||
|
|
|
@ -8,7 +8,7 @@ def get_layer_list(self, context):
|
|||
return [('None', 'None','None')]
|
||||
if not context.object:
|
||||
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:
|
||||
# except:
|
||||
# return [("", "", "")]
|
||||
|
|
|
@ -30,7 +30,7 @@ def layer_name_build(layer, prefix='', desc='', suffix=''):
|
|||
|
||||
prefs = get_addon_prefs()
|
||||
sep = prefs.separator
|
||||
name = old = layer.info
|
||||
name = old = layer.name
|
||||
|
||||
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
|
||||
new = f'{grp}{tag}{name}{sfix}'
|
||||
|
||||
layer.info = new
|
||||
layer.name = new
|
||||
|
||||
## update name in modifier targets
|
||||
if old != new:
|
||||
|
@ -93,7 +93,7 @@ def layer_name_build(layer, prefix='', prefix2='', desc='', suffix=''):
|
|||
|
||||
prefs = get_addon_prefs()
|
||||
sep = prefs.separator
|
||||
name = layer.info
|
||||
name = layer.name
|
||||
|
||||
pattern = pattern.replace('_', sep) # set separator
|
||||
|
||||
|
@ -122,7 +122,7 @@ def layer_name_build(layer, prefix='', prefix2='', desc='', suffix=''):
|
|||
p4 = sep + suffix.upper().strip()
|
||||
|
||||
new = f'{p1}{p2}{p3}{p4}'
|
||||
layer.info = new
|
||||
layer.name = new
|
||||
"""
|
||||
|
||||
## multi-prefix solution (Caps letters)
|
||||
|
@ -172,14 +172,14 @@ class GPTB_OT_layer_name_build(Operator):
|
|||
def grp_toggle(l, mode='TOGGLE'):
|
||||
'''take mode in (TOGGLE, GROUP, UNGROUP) '''
|
||||
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'):
|
||||
# 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'):
|
||||
# found : delete group prefix
|
||||
l.info = res.group(2)
|
||||
l.name = res.group(2)
|
||||
|
||||
|
||||
class GPTB_OT_layer_group_toggle(Operator):
|
||||
|
@ -220,18 +220,18 @@ class GPTB_OT_layer_new_group(Operator):
|
|||
self.report({'ERROR'}, 'no layer active')
|
||||
return {"CANCELLED"}
|
||||
|
||||
res = re.search(PATTERN, act.info)
|
||||
res = re.search(PATTERN, act.name)
|
||||
if not res:
|
||||
self.report({'ERROR'}, 'Could not create a group name, create a layer manually')
|
||||
return {"CANCELLED"}
|
||||
|
||||
name = res.group('name').strip(' -')
|
||||
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"}
|
||||
|
||||
if name in [l.info.strip(' -') for l in gpl]:
|
||||
self.report({'WARNING'}, f'Name already exists: {act.info}')
|
||||
if name in [l.name.strip(' -') for l in gpl]:
|
||||
self.report({'WARNING'}, f'Name already exists: {act.name}')
|
||||
return {"FINISHED"}
|
||||
|
||||
grp_toggle(act, mode='GROUP')
|
||||
|
@ -272,7 +272,7 @@ def build_layers_targets_from_dopesheet(context):
|
|||
|
||||
# apply search filter
|
||||
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
|
||||
|
||||
|
@ -330,35 +330,35 @@ class GPTB_OT_select_set_same_prefix(Operator):
|
|||
self.report({'ERROR'}, 'No active layer to base action')
|
||||
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:
|
||||
self.report({'ERROR'}, f'Error scanning {act.info}')
|
||||
self.report({'ERROR'}, f'Error scanning {act.name}')
|
||||
return {"CANCELLED"}
|
||||
|
||||
namespace = res.group('tag')
|
||||
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"}
|
||||
|
||||
if self.mode == 'SELECT':
|
||||
## with split
|
||||
# namespace = act.info.split(sep,1)[0]
|
||||
# namespace_bool_list = [l.info.split(sep,1)[0] == namespace for l in gpl]
|
||||
# namespace = act.name.split(sep,1)[0]
|
||||
# namespace_bool_list = [l.name.split(sep,1)[0] == namespace for l in gpl]
|
||||
|
||||
## 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)
|
||||
|
||||
## don't work Need Foreach set per gp
|
||||
# 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():
|
||||
# check namespace + restrict selection to visible layers according to filters
|
||||
# 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)
|
||||
|
||||
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')
|
||||
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
|
||||
if self.mode == '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
|
||||
# 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
|
||||
|
||||
"""
|
||||
|
@ -463,38 +463,38 @@ def replace_layer_name(target, replacement, selected_only=True, prefix_only=True
|
|||
gpl = bpy.context.object.data.layers
|
||||
|
||||
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:
|
||||
lays = [l for l in gpl] # exclude : if l.info != 'background'
|
||||
lays = [l for l in gpl] # exclude : if l.name != 'background'
|
||||
|
||||
ct = 0
|
||||
for l in lays:
|
||||
old = l.info
|
||||
old = l.name
|
||||
if regex:
|
||||
new = re.sub(target, replacement, l.info)
|
||||
new = re.sub(target, replacement, l.name)
|
||||
if old != new:
|
||||
l.info = new
|
||||
l.name = new
|
||||
print('rename:', old, '-->', new)
|
||||
ct += 1
|
||||
continue
|
||||
|
||||
if prefix_only:
|
||||
if not sep in l.info:
|
||||
if not sep in l.name:
|
||||
# only if separator exists
|
||||
continue
|
||||
splited = l.info.split(sep)
|
||||
splited = l.name.split(sep)
|
||||
prefix = splited[0]
|
||||
new_prefix = prefix.replace(target, replacement)
|
||||
if prefix != new_prefix:
|
||||
splited[0] = new_prefix
|
||||
l.info = sep.join(splited)
|
||||
print('rename:', old, '-->', l.info)
|
||||
l.name = sep.join(splited)
|
||||
print('rename:', old, '-->', l.name)
|
||||
ct += 1
|
||||
|
||||
else:
|
||||
new = l.info.replace(target, replacement)
|
||||
new = l.name.replace(target, replacement)
|
||||
if old != new:
|
||||
l.info = new
|
||||
l.name = new
|
||||
print('rename:', old, '-->', new)
|
||||
ct += 1
|
||||
return ct
|
||||
|
@ -663,7 +663,7 @@ def obj_layer_name_callback():
|
|||
for l in ob.data.layers:
|
||||
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:
|
||||
return
|
||||
if not res.group('name'):
|
||||
|
|
|
@ -47,7 +47,7 @@ class GP_OT_pick_closest_layer(Operator):
|
|||
def draw(self, context):
|
||||
layout = self.layout
|
||||
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')
|
||||
|
||||
def modal(self, context, event):
|
||||
|
@ -117,7 +117,7 @@ class GP_OT_pick_closest_layer(Operator):
|
|||
## debug show trigger time
|
||||
# print(f'Trigger time {time() - self.t0:.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'}
|
||||
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ from . import utils
|
|||
# return [('None', 'None','None')]
|
||||
# if not context.object:
|
||||
# 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
|
||||
# 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'
|
||||
row = col.row()
|
||||
row.alignment = 'LEFT'
|
||||
op = col.operator('gp.move_material_to_layer', text=l.info, icon=icon, emboss=False)
|
||||
op.layer_name = l.info
|
||||
op = col.operator('gp.move_material_to_layer', text=l.name, icon=icon, emboss=False)
|
||||
op.layer_name = l.name
|
||||
op.copy = self.copy
|
||||
|
||||
def execute(self, context):
|
||||
|
|
|
@ -74,7 +74,7 @@ class GPT_OT_auto_tint_gp_layers(bpy.types.Operator):
|
|||
# namespace_order
|
||||
namespaces=[]
|
||||
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:
|
||||
namespaces.append(ns)
|
||||
|
||||
|
@ -88,14 +88,14 @@ class GPT_OT_auto_tint_gp_layers(bpy.types.Operator):
|
|||
### step from 0.1 to 0.9
|
||||
|
||||
for i, l in enumerate(gpl):
|
||||
if l.info.lower() not in ('background',):
|
||||
if l.name.lower() not in ('background',):
|
||||
print()
|
||||
print('>', l.info)
|
||||
ns= l.info.lower().split(separator, 1)[0]#get namespace from separator
|
||||
print('>', l.name)
|
||||
ns= l.name.lower().split(separator, 1)[0]#get namespace from separator
|
||||
print("namespace", ns)#Dbg
|
||||
|
||||
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:
|
||||
h = translate_range((i + hue_offset/100)%layer_ct, 0, layer_ct, 0.1, 0.9)
|
||||
|
|
|
@ -26,7 +26,7 @@ def update_layer_name(self, context):
|
|||
if not context.object.data.layers.active:
|
||||
return
|
||||
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):
|
||||
|
|
Loading…
Reference in New Issue