[Bf-blender-cvs] [22944ea91e7] greasepencil-object: GPencil: Remove duplicated code and cleanup
Antonio Vazquez
noreply at git.blender.org
Thu May 6 18:59:13 CEST 2021
Commit: 22944ea91e7f79304fb9e98bd0f3e8f4405199de
Author: Antonio Vazquez
Date: Thu May 6 18:59:09 2021 +0200
Branches: greasepencil-object
https://developer.blender.org/rB22944ea91e7f79304fb9e98bd0f3e8f4405199de
GPencil: Remove duplicated code and cleanup
===================================================================
M release/scripts/startup/bl_ui/space_view3d.py
===================================================================
diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index 07fd4688e7c..8e4f1075a17 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -4978,24 +4978,28 @@ class VIEW3D_MT_gpencil_copy_layer(Menu):
layout.label(text="No layer to copy", icon='ERROR')
+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
- view_layer = context.view_layer
- obact = context.active_object
-
- done = False
- 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 = True
- done = True
-
- if done is False:
- layout.label(text="No destination object", icon='ERROR')
+ gpencil_material_menu_items(context, layout, True)
class VIEW3D_MT_gpencil_append_all_materials(Menu):
@@ -5003,19 +5007,7 @@ class VIEW3D_MT_gpencil_append_all_materials(Menu):
def draw(self, context):
layout = self.layout
- view_layer = context.view_layer
- obact = context.active_object
-
- done = False
- 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 = False
- done = True
-
- if done is False:
- layout.label(text="No destination object", icon='ERROR')
+ gpencil_material_menu_items(context, layout, False)
class VIEW3D_MT_edit_gpencil(Menu):
More information about the Bf-blender-cvs
mailing list