feat: transfer materials to objects
1.0.3: - feat: add "Append Materials To Selected" to material submenu. Append materials to other selected GP objects if there aren't there.gpv2 v1.0.3
parent
d7da95ac5d
commit
43797ff590
|
@ -243,11 +243,51 @@ class GPTB_OT_load_blend_palette(bpy.types.Operator, ImportHelper):
|
||||||
|
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
|
class GPTB_OT_copy_active_to_selected_palette(bpy.types.Operator):
|
||||||
|
bl_idname = "gp.copy_active_to_selected_palette"
|
||||||
|
bl_label = "Append Materials To Selected"
|
||||||
|
bl_description = "Copy all the materials of the active GP objects to the material stack of all the other selected GP"
|
||||||
|
bl_options = {"REGISTER"} # , "INTERNAL"
|
||||||
|
|
||||||
|
# path_to_pal : bpy.props.StringProperty(name="paht to palette", description="path to the palette", default="")
|
||||||
|
@classmethod
|
||||||
|
def poll(cls, context):
|
||||||
|
return context.object and context.object.type == 'GPENCIL'
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
ob = context.object
|
||||||
|
if not len(ob.data.materials):
|
||||||
|
self.report({'ERROR'}, 'No materials to transfer')
|
||||||
|
return {"CANCELLED"}
|
||||||
|
|
||||||
|
selection = [o for o in context.selected_objects if o.type == 'GPENCIL' and o != ob]
|
||||||
|
|
||||||
|
if not selection:
|
||||||
|
self.report({'ERROR'}, 'Need to have other Grease pencil objects selected to receive active object materials')
|
||||||
|
return {"CANCELLED"}
|
||||||
|
|
||||||
|
ct = 0
|
||||||
|
for o in selection:
|
||||||
|
for mat in ob.data.materials:
|
||||||
|
if mat in o.data.materials[:]:
|
||||||
|
continue
|
||||||
|
o.data.materials.append(mat)
|
||||||
|
ct += 1
|
||||||
|
|
||||||
|
if ct:
|
||||||
|
self.report({'INFO'}, f'{ct} Materials appended')
|
||||||
|
else:
|
||||||
|
self.report({'WARNING'}, 'All materials are already in other selected object')
|
||||||
|
|
||||||
|
return {"FINISHED"}
|
||||||
|
|
||||||
classes = (
|
classes = (
|
||||||
GPTB_OT_load_palette,
|
GPTB_OT_load_palette,
|
||||||
GPTB_OT_save_palette,
|
GPTB_OT_save_palette,
|
||||||
GPTB_OT_load_default_palette,
|
GPTB_OT_load_default_palette,
|
||||||
GPTB_OT_load_blend_palette,
|
GPTB_OT_load_blend_palette,
|
||||||
|
GPTB_OT_copy_active_to_selected_palette,
|
||||||
)
|
)
|
||||||
|
|
||||||
def register():
|
def register():
|
||||||
|
|
15
README.md
15
README.md
|
@ -73,6 +73,17 @@ Also Possible to copy whole selected layers.
|
||||||
|
|
||||||
- Auto update : you have an updater in the addon preference tabs (use the [CGcookie addon updater](https://github.com/CGCookie/blender-addon-updater))
|
- Auto update : you have an updater in the addon preference tabs (use the [CGcookie addon updater](https://github.com/CGCookie/blender-addon-updater))
|
||||||
|
|
||||||
|
|
||||||
|
**Palette management**
|
||||||
|
|
||||||
|
In material submenu you have mutliple new entry:
|
||||||
|
|
||||||
|
- Copy Materials To Selected : copy all material to other selected GP (difference with Ctrl+L > materials is that it doesn't erase materials, only append those that are not in other's materials stack)
|
||||||
|
|
||||||
|
- Load/Save Json palette : Save/load materials externally to a json file from/to the active material stack.
|
||||||
|
|
||||||
|
- Load Color palette : same as the load above exept it loads directly from a blend file (all the material that the blend contains)
|
||||||
|
|
||||||
### Where ?
|
### Where ?
|
||||||
|
|
||||||
Panel in sidebar : 3D view > sidebar 'N' > Gpencil
|
Panel in sidebar : 3D view > sidebar 'N' > Gpencil
|
||||||
|
@ -101,6 +112,10 @@ Panel in sidebar : 3D view > sidebar 'N' > Gpencil
|
||||||
|
|
||||||
## Changelog:
|
## Changelog:
|
||||||
|
|
||||||
|
1.0.3:
|
||||||
|
|
||||||
|
- feat: add "Append Materials To Selected" to material submenu. Append materials to other selected GP objects if there aren't there.
|
||||||
|
|
||||||
1.0.2:
|
1.0.2:
|
||||||
|
|
||||||
- pref: Added option to disable always remap relative on save in addon-preference
|
- pref: Added option to disable always remap relative on save in addon-preference
|
||||||
|
|
|
@ -316,6 +316,7 @@ def palette_manager_menu(self, context):
|
||||||
layout.separator()
|
layout.separator()
|
||||||
prefs = get_addon_prefs()
|
prefs = get_addon_prefs()
|
||||||
|
|
||||||
|
layout.operator("gp.copy_active_to_selected_palette", text='Append Materials To Selected', icon='MATERIAL')
|
||||||
layout.operator("gp.load_palette", text='Load json Palette', icon='IMPORT').filepath = prefs.palette_path
|
layout.operator("gp.load_palette", text='Load json Palette', icon='IMPORT').filepath = prefs.palette_path
|
||||||
layout.operator("gp.save_palette", text='Save json Palette', icon='EXPORT').filepath = prefs.palette_path
|
layout.operator("gp.save_palette", text='Save json Palette', icon='EXPORT').filepath = prefs.palette_path
|
||||||
layout.operator("gp.load_blend_palette", text='Load color Palette', icon='COLOR').filepath = prefs.palette_path
|
layout.operator("gp.load_blend_palette", text='Load color Palette', icon='COLOR').filepath = prefs.palette_path
|
||||||
|
|
|
@ -15,7 +15,7 @@ bl_info = {
|
||||||
"name": "GP toolbox",
|
"name": "GP toolbox",
|
||||||
"description": "Set of tools for Grease Pencil in animation production",
|
"description": "Set of tools for Grease Pencil in animation production",
|
||||||
"author": "Samuel Bernou",
|
"author": "Samuel Bernou",
|
||||||
"version": (1, 0, 2),
|
"version": (1, 0, 3),
|
||||||
"blender": (2, 91, 0),
|
"blender": (2, 91, 0),
|
||||||
"location": "sidebar (N menu) > Gpencil > Toolbox / Gpencil properties",
|
"location": "sidebar (N menu) > Gpencil > Toolbox / Gpencil properties",
|
||||||
"warning": "",
|
"warning": "",
|
||||||
|
|
Loading…
Reference in New Issue