Add Copy material to layer
3.3.0 - added: `Move Material To Layer` has now option to copy instead of moving in pop-up menu.gpv2 v3.3.0
parent
19e26f8cee
commit
c02b890915
|
@ -1,5 +1,9 @@
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
3.3.0
|
||||||
|
|
||||||
|
- added: `Move Material To Layer` has now option to copy instead of moving in pop-up menu.
|
||||||
|
|
||||||
3.2.0
|
3.2.0
|
||||||
|
|
||||||
- added: UI settings to show GP tool settings placement and orientation
|
- added: UI settings to show GP tool settings placement and orientation
|
||||||
|
|
|
@ -28,10 +28,14 @@ class GPTB_OT_move_material_to_layer(Operator) :
|
||||||
bl_label = 'Move Material To Layer'
|
bl_label = 'Move Material To Layer'
|
||||||
bl_description = 'Move active material to an existing or new layer'
|
bl_description = 'Move active material to an existing or new layer'
|
||||||
bl_options = {"REGISTER", "UNDO", "INTERNAL"}
|
bl_options = {"REGISTER", "UNDO", "INTERNAL"}
|
||||||
|
|
||||||
|
|
||||||
layer_name : bpy.props.StringProperty(
|
layer_name : bpy.props.StringProperty(
|
||||||
name='Layer Name', default='', options={'SKIP_SAVE'})
|
name='Layer Name', default='', options={'SKIP_SAVE'})
|
||||||
|
|
||||||
|
copy : bpy.props.BoolProperty(
|
||||||
|
name='Copy to layer', default=False,
|
||||||
|
description='Copy strokes to layer instead of moving',
|
||||||
|
options={'SKIP_SAVE'})
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def poll(cls, context):
|
def poll(cls, context):
|
||||||
|
@ -53,7 +57,9 @@ class GPTB_OT_move_material_to_layer(Operator) :
|
||||||
def draw(self, context):
|
def draw(self, context):
|
||||||
layout = self.layout
|
layout = self.layout
|
||||||
# layout.operator_context = "INVOKE_DEFAULT"
|
# layout.operator_context = "INVOKE_DEFAULT"
|
||||||
layout.label(text=f'Move material "{self.mat_name}" to layer:', icon='MATERIAL')
|
layout.prop(self, 'copy', text='Copy Strokes')
|
||||||
|
action_label = 'Copy' if self.copy else 'Move'
|
||||||
|
layout.label(text=f'{action_label} material "{self.mat_name}" to layer:', icon='MATERIAL')
|
||||||
|
|
||||||
col = layout.column()
|
col = layout.column()
|
||||||
col.prop(self, 'layer_name', text='', icon='ADD')
|
col.prop(self, 'layer_name', text='', icon='ADD')
|
||||||
|
@ -66,7 +72,9 @@ 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'
|
||||||
col.operator('gp.move_material_to_layer', text=l.info, icon=icon, emboss=False).layer_name = l.info
|
op = col.operator('gp.move_material_to_layer', text=l.info, icon=icon, emboss=False)
|
||||||
|
op.layer_name = l.info
|
||||||
|
op.copy = self.copy
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
if not self.layer_name:
|
if not self.layer_name:
|
||||||
|
@ -132,8 +140,9 @@ class GPTB_OT_move_material_to_layer(Operator) :
|
||||||
|
|
||||||
# print('Removing frames') # Dbg
|
# print('Removing frames') # Dbg
|
||||||
## Remove from source frame (f)
|
## Remove from source frame (f)
|
||||||
for s in reversed(stroke_to_delete):
|
if not self.copy:
|
||||||
f.strokes.remove(s)
|
for s in reversed(stroke_to_delete):
|
||||||
|
f.strokes.remove(s)
|
||||||
|
|
||||||
## ? Remove frame if layer is empty ? -> probably not, will show previous frame
|
## ? Remove frame if layer is empty ? -> probably not, will show previous frame
|
||||||
|
|
||||||
|
@ -148,7 +157,10 @@ class GPTB_OT_move_material_to_layer(Operator) :
|
||||||
total += fct
|
total += fct
|
||||||
|
|
||||||
report_type = 'INFO' if total else 'WARNING'
|
report_type = 'INFO' if total else 'WARNING'
|
||||||
self.report({report_type}, f'Moved {total} frames accross {oct} object(s)')
|
if self.copy:
|
||||||
|
self.report({report_type}, f'Copied {total} frames accross {oct} object(s)')
|
||||||
|
else:
|
||||||
|
self.report({report_type}, f'Moved {total} frames accross {oct} object(s)')
|
||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,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": (3, 2, 0),
|
"version": (3, 3, 0),
|
||||||
"blender": (4, 0, 0),
|
"blender": (4, 0, 0),
|
||||||
"location": "Sidebar (N menu) > Gpencil > Toolbox / Gpencil properties",
|
"location": "Sidebar (N menu) > Gpencil > Toolbox / Gpencil properties",
|
||||||
"warning": "",
|
"warning": "",
|
||||||
|
|
Loading…
Reference in New Issue