Remove useless pseudo groups now that there is a native group system
parent
c8763f5ca4
commit
4d6dc06e4e
|
@ -21,6 +21,7 @@ from .utils import get_addon_prefs, is_vector_close
|
||||||
# PATTERN = r'^(?P<grp>-\s)?(?P<tag>[A-Z]{2}_)?(?P<tag2>[A-Z]{1,6}_)?(?P<name>.*?)(?P<sfix>_[A-Z]{2})?(?P<inc>\.\d{3})?$' # numering
|
# PATTERN = r'^(?P<grp>-\s)?(?P<tag>[A-Z]{2}_)?(?P<tag2>[A-Z]{1,6}_)?(?P<name>.*?)(?P<sfix>_[A-Z]{2})?(?P<inc>\.\d{3})?$' # numering
|
||||||
PATTERN = r'^(?P<grp>-\s)?(?P<tag>[A-Z]{2}_)?(?P<name>.*?)(?P<sfix>_[A-Z]{2})?(?P<inc>\.\d{3})?$' # numering
|
PATTERN = r'^(?P<grp>-\s)?(?P<tag>[A-Z]{2}_)?(?P<name>.*?)(?P<sfix>_[A-Z]{2})?(?P<inc>\.\d{3})?$' # numering
|
||||||
|
|
||||||
|
# TODO: allow a more flexible prefix pattern
|
||||||
|
|
||||||
def layer_name_build(layer, prefix='', desc='', suffix=''):
|
def layer_name_build(layer, prefix='', desc='', suffix=''):
|
||||||
'''GET a layer and argument to build and assign name
|
'''GET a layer and argument to build and assign name
|
||||||
|
@ -155,13 +156,16 @@ class GPTB_OT_layer_name_build(Operator):
|
||||||
gpl = ob.data.layers
|
gpl = ob.data.layers
|
||||||
act = gpl.active
|
act = gpl.active
|
||||||
if not act:
|
if not act:
|
||||||
self.report({'ERROR'}, 'no layer active')
|
act = ob.data.layer_groups.active
|
||||||
|
|
||||||
|
if not act:
|
||||||
|
self.report({'ERROR'}, 'No layer active')
|
||||||
return {"CANCELLED"}
|
return {"CANCELLED"}
|
||||||
|
|
||||||
layer_name_build(act, prefix=self.prefix, desc=self.desc, suffix=self.suffix)
|
layer_name_build(act, prefix=self.prefix, desc=self.desc, suffix=self.suffix)
|
||||||
|
|
||||||
## Deactivate multi-selection on layer !
|
## /!\ Deactivate multi-selection on layer !
|
||||||
## somethimes it affect a random layer that is still considered selected
|
## Somethimes it affect a random layer that is still considered selected
|
||||||
# for l in gpl:
|
# for l in gpl:
|
||||||
# if l.select or l == act:
|
# if l.select or l == act:
|
||||||
# layer_name_build(l, prefix=self.prefix, desc=self.desc, suffix=self.suffix)
|
# layer_name_build(l, prefix=self.prefix, desc=self.desc, suffix=self.suffix)
|
||||||
|
@ -169,79 +173,6 @@ class GPTB_OT_layer_name_build(Operator):
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
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.name)
|
|
||||||
if not res and mode in ('TOGGLE', 'GROUP'):
|
|
||||||
# No gpr : add group prefix after stripping all space and dash
|
|
||||||
l.name = grp_item_id + l.name.lstrip(' -')
|
|
||||||
|
|
||||||
elif res and mode in ('TOGGLE', 'UNGROUP'):
|
|
||||||
# found : delete group prefix
|
|
||||||
l.name = res.group(2)
|
|
||||||
|
|
||||||
|
|
||||||
class GPTB_OT_layer_group_toggle(Operator):
|
|
||||||
bl_idname = "gp.layer_group_toggle"
|
|
||||||
bl_label = "Group Toggle"
|
|
||||||
bl_description = "Group or ungroup a layer"
|
|
||||||
bl_options = {"REGISTER", "UNDO"}
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def poll(cls, context):
|
|
||||||
return True
|
|
||||||
|
|
||||||
# group : StringProperty(default='', options={'SKIP_SAVE'})
|
|
||||||
|
|
||||||
def execute(self, context):
|
|
||||||
ob = context.object
|
|
||||||
gpl = ob.data.layers
|
|
||||||
act = gpl.active
|
|
||||||
if not act:
|
|
||||||
self.report({'ERROR'}, 'no layer active')
|
|
||||||
return {"CANCELLED"}
|
|
||||||
for l in gpl:
|
|
||||||
if l.select or l == act:
|
|
||||||
grp_toggle(l)
|
|
||||||
return {"FINISHED"}
|
|
||||||
|
|
||||||
class GPTB_OT_layer_new_group(Operator):
|
|
||||||
bl_idname = "gp.layer_new_group"
|
|
||||||
bl_label = "New Group"
|
|
||||||
bl_description = "Create a group from active layer"
|
|
||||||
bl_options = {"REGISTER", "UNDO"}
|
|
||||||
|
|
||||||
def execute(self, context):
|
|
||||||
ob = context.object
|
|
||||||
gpl = ob.data.layers
|
|
||||||
act = gpl.active
|
|
||||||
if not act:
|
|
||||||
self.report({'ERROR'}, 'no layer active')
|
|
||||||
return {"CANCELLED"}
|
|
||||||
|
|
||||||
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.name}')
|
|
||||||
return {"CANCELLED"}
|
|
||||||
|
|
||||||
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')
|
|
||||||
n = gpl.new(name, set_active=False)
|
|
||||||
n.use_onion_skinning = n.use_lights = False
|
|
||||||
n.hide = True
|
|
||||||
n.opacity = 0
|
|
||||||
return {"FINISHED"}
|
|
||||||
|
|
||||||
|
|
||||||
#-## SELECTION MANAGEMENT ##-#
|
#-## SELECTION MANAGEMENT ##-#
|
||||||
|
|
||||||
def activate_channel_group_color(context):
|
def activate_channel_group_color(context):
|
||||||
|
@ -818,8 +749,6 @@ def unregister_keymaps():
|
||||||
classes=(
|
classes=(
|
||||||
GPTB_OT_rename_gp_layer,
|
GPTB_OT_rename_gp_layer,
|
||||||
GPTB_OT_layer_name_build,
|
GPTB_OT_layer_name_build,
|
||||||
GPTB_OT_layer_group_toggle,
|
|
||||||
GPTB_OT_layer_new_group,
|
|
||||||
GPTB_OT_select_set_same_prefix,
|
GPTB_OT_select_set_same_prefix,
|
||||||
GPTB_OT_select_set_same_color,
|
GPTB_OT_select_set_same_color,
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue