Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntonio Vazquez <blendergit@gmail.com>2021-05-07 19:27:47 +0300
committerAntonio Vazquez <blendergit@gmail.com>2021-05-07 19:27:58 +0300
commit960535ddf3446204dbfcc0f23040bdb74f7a9720 (patch)
treec3e943e8a0f06298e048bde25312634e33b893fc /release/scripts/startup/bl_ui/space_view3d.py
parentc2b6dc7e53ae30de0d75a97aeda5844f9ea6506f (diff)
GPencil: New Append operators
Now it's possible to append materials of one grease pencil object into another one. The operator allows active material or all materials. Also, the Layer Copy To Object has been renamed to Layer Append to Object to keep consistency and now allows to append all layers at once.
Diffstat (limited to 'release/scripts/startup/bl_ui/space_view3d.py')
-rw-r--r--release/scripts/startup/bl_ui/space_view3d.py86
1 files changed, 68 insertions, 18 deletions
diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index bdc924e3197..4b06a2df3a0 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -4956,26 +4956,73 @@ class VIEW3D_MT_assign_material(Menu):
icon='LAYER_ACTIVE' if mat == mat_active else 'BLANK1').material = mat.name
-class VIEW3D_MT_gpencil_copy_layer(Menu):
- bl_label = "Copy Layer to Object"
+def gpencil_layer_append_menu_items(context, layout, only_active):
+ done = False
+ view_layer = context.view_layer
+ obact = context.active_object
+ gpl = context.active_gpencil_layer
+
+ done = False
+ if gpl is not None:
+ for ob in view_layer.objects:
+ if ob.type == 'GPENCIL' and ob != obact:
+ op = layout.operator("gpencil.layer_duplicate_object", text=ob.name)
+ op.object = ob.name
+ op.only_active = only_active
+ done = True
+
+ if done is False:
+ layout.label(text="No destination object", icon='ERROR')
+ else:
+ layout.label(text="No layer to copy", icon='ERROR')
+
+
+class VIEW3D_MT_gpencil_append_active_layer(Menu):
+ bl_label = "Append Active Layer to Object"
def draw(self, context):
layout = self.layout
- view_layer = context.view_layer
- obact = context.active_object
- gpl = context.active_gpencil_layer
-
- done = False
- if gpl is not None:
- for ob in view_layer.objects:
- if ob.type == 'GPENCIL' and ob != obact:
- layout.operator("gpencil.layer_duplicate_object", text=ob.name).object = ob.name
- done = True
-
- if done is False:
- layout.label(text="No destination object", icon='ERROR')
- else:
- layout.label(text="No layer to copy", icon='ERROR')
+ gpencil_layer_append_menu_items(context, layout, True)
+
+
+class VIEW3D_MT_gpencil_append_all_layers(Menu):
+ bl_label = "Append All Layers to Object"
+
+ def draw(self, context):
+ layout = self.layout
+ gpencil_layer_append_menu_items(context, layout, False)
+
+
+def gpencil_material_menu_items(context, layout, only_selected):
+ done = False
+ view_layer = context.view_layer
+ obact = context.active_object
+
+ for ob in view_layer.objects:
+ if ob.type == 'GPENCIL' and ob != obact:
+ op = layout.operator("gpencil.materials_append_to_object", text=ob.name)
+ op.object = ob.name
+ op.only_selected = only_selected
+ done = True
+
+ if done is False:
+ layout.label(text="No destination object", icon='ERROR')
+
+
+class VIEW3D_MT_gpencil_append_active_material(Menu):
+ bl_label = "Append Active Material to Object"
+
+ def draw(self, context):
+ layout = self.layout
+ gpencil_material_menu_items(context, layout, True)
+
+
+class VIEW3D_MT_gpencil_append_all_materials(Menu):
+ bl_label = "Append All Materials to Object"
+
+ def draw(self, context):
+ layout = self.layout
+ gpencil_material_menu_items(context, layout, False)
class VIEW3D_MT_edit_gpencil(Menu):
@@ -7642,7 +7689,10 @@ classes = (
VIEW3D_MT_weight_gpencil,
VIEW3D_MT_gpencil_animation,
VIEW3D_MT_gpencil_simplify,
- VIEW3D_MT_gpencil_copy_layer,
+ VIEW3D_MT_gpencil_append_active_layer,
+ VIEW3D_MT_gpencil_append_all_layers,
+ VIEW3D_MT_gpencil_append_active_material,
+ VIEW3D_MT_gpencil_append_all_materials,
VIEW3D_MT_gpencil_autoweights,
VIEW3D_MT_gpencil_edit_context_menu,
VIEW3D_MT_edit_curve,