Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
462a013d98 | ||
|
5aeb21342a | ||
|
abe526d046 | ||
|
f40d4d7a58 | ||
|
cca9494ae4 | ||
|
e51cc474d6 |
22
CHANGELOG.md
22
CHANGELOG.md
@ -1,5 +1,27 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
3.3.5
|
||||||
|
|
||||||
|
- added: copy paste option to copy only existing frame without baking the whole move
|
||||||
|
|
||||||
|
3.3.4
|
||||||
|
|
||||||
|
- fixed: Error when trying to load addon in 4.3.0+ (prevent loading without error, print about incompatibility in console)
|
||||||
|
|
||||||
|
3.3.3
|
||||||
|
|
||||||
|
- added: list collections visibility conflict from search menu with dev extras (backported from gpv3)
|
||||||
|
|
||||||
|
3.3.2
|
||||||
|
|
||||||
|
- added: fix cursor follow and add optional target object (backported from gpv3)
|
||||||
|
|
||||||
|
3.3.1
|
||||||
|
|
||||||
|
- added: improve file checker and visibility conflict feature (backported from gpv3)
|
||||||
|
|
||||||
|
-- GPv2 code - Above this line, version is separated from 4.3+ version (using GPv3) --
|
||||||
|
|
||||||
3.3.0
|
3.3.0
|
||||||
|
|
||||||
- added: `Move Material To Layer` has now option to copy instead of moving in pop-up menu.
|
- added: `Move Material To Layer` has now option to copy instead of moving in pop-up menu.
|
||||||
|
@ -512,6 +512,9 @@ class GPCLIP_OT_copy_multi_strokes(bpy.types.Operator):
|
|||||||
def poll(cls, context):
|
def poll(cls, context):
|
||||||
return context.object and context.object.type == 'GPENCIL'
|
return context.object and context.object.type == 'GPENCIL'
|
||||||
|
|
||||||
|
bake_moves : bpy.props.BoolProperty(name='Bake Move', default=True,
|
||||||
|
description='Copy every frame where object has moved, else copy only existing frames)')
|
||||||
|
|
||||||
pressure : bpy.props.BoolProperty(name='pressure', default=True,
|
pressure : bpy.props.BoolProperty(name='pressure', default=True,
|
||||||
description='Dump point pressure attribute (already skipped if at default value)')
|
description='Dump point pressure attribute (already skipped if at default value)')
|
||||||
strength : bpy.props.BoolProperty(name='strength', default=True,
|
strength : bpy.props.BoolProperty(name='strength', default=True,
|
||||||
@ -534,6 +537,7 @@ class GPCLIP_OT_copy_multi_strokes(bpy.types.Operator):
|
|||||||
layout=self.layout
|
layout=self.layout
|
||||||
layout.use_property_split = True
|
layout.use_property_split = True
|
||||||
col = layout.column()
|
col = layout.column()
|
||||||
|
col.prop(self, 'bake_moves')
|
||||||
col.label(text='Keep following point attributes:')
|
col.label(text='Keep following point attributes:')
|
||||||
col.prop(self, 'pressure')
|
col.prop(self, 'pressure')
|
||||||
col.prop(self, 'strength')
|
col.prop(self, 'strength')
|
||||||
@ -544,7 +548,6 @@ class GPCLIP_OT_copy_multi_strokes(bpy.types.Operator):
|
|||||||
return
|
return
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
bake_moves = True
|
|
||||||
skip_empty_frame = False
|
skip_empty_frame = False
|
||||||
|
|
||||||
org_frame = context.scene.frame_current
|
org_frame = context.scene.frame_current
|
||||||
@ -559,7 +562,7 @@ class GPCLIP_OT_copy_multi_strokes(bpy.types.Operator):
|
|||||||
self.report({'ERROR'}, 'No layers selected in GP dopesheet (needs to be visible and selected to be copied)\nHint: Changing active layer reset selection to active only')
|
self.report({'ERROR'}, 'No layers selected in GP dopesheet (needs to be visible and selected to be copied)\nHint: Changing active layer reset selection to active only')
|
||||||
return {"CANCELLED"}
|
return {"CANCELLED"}
|
||||||
|
|
||||||
if not bake_moves: # copy only drawed frames as is.
|
if not self.bake_moves: # copy only drawed frames as is.
|
||||||
for l in layerpool:
|
for l in layerpool:
|
||||||
if not l.frames:
|
if not l.frames:
|
||||||
continue# skip empty layers
|
continue# skip empty layers
|
||||||
|
@ -3,6 +3,7 @@ import bpy
|
|||||||
import mathutils
|
import mathutils
|
||||||
from bpy_extras import view3d_utils
|
from bpy_extras import view3d_utils
|
||||||
from .utils import get_gp_draw_plane, region_to_location, get_view_origin_position
|
from .utils import get_gp_draw_plane, region_to_location, get_view_origin_position
|
||||||
|
from bpy.app.handlers import persistent
|
||||||
|
|
||||||
## override all sursor snap shortcut with this in keymap
|
## override all sursor snap shortcut with this in keymap
|
||||||
class GPTB_OT_cusor_snap(bpy.types.Operator):
|
class GPTB_OT_cusor_snap(bpy.types.Operator):
|
||||||
@ -110,15 +111,20 @@ prev_matrix = None
|
|||||||
|
|
||||||
# @call_once(bpy.app.handlers.frame_change_post)
|
# @call_once(bpy.app.handlers.frame_change_post)
|
||||||
|
|
||||||
|
## used in properties file to register in boolprop update
|
||||||
def cursor_follow_update(self, context):
|
def cursor_follow_update(self, context):
|
||||||
'''append or remove cursor_follow handler according a boolean'''
|
'''append or remove cursor_follow handler according a boolean'''
|
||||||
|
ob = bpy.context.object
|
||||||
|
if bpy.context.scene.gptoolprops.cursor_follow_target:
|
||||||
|
## override with target object is specified
|
||||||
|
ob = bpy.context.scene.gptoolprops.cursor_follow_target
|
||||||
global prev_matrix
|
global prev_matrix
|
||||||
# imported in properties to register in boolprop update
|
# imported in properties to register in boolprop update
|
||||||
if self.cursor_follow:#True
|
if self.cursor_follow:#True
|
||||||
|
if ob:
|
||||||
|
# out of below condition to be called when setting target as well
|
||||||
|
prev_matrix = ob.matrix_world.copy()
|
||||||
if not cursor_follow.__name__ in [hand.__name__ for hand in bpy.app.handlers.frame_change_post]:
|
if not cursor_follow.__name__ in [hand.__name__ for hand in bpy.app.handlers.frame_change_post]:
|
||||||
if context.object:
|
|
||||||
prev_matrix = context.object.matrix_world
|
|
||||||
|
|
||||||
bpy.app.handlers.frame_change_post.append(cursor_follow)
|
bpy.app.handlers.frame_change_post.append(cursor_follow)
|
||||||
|
|
||||||
else:#False
|
else:#False
|
||||||
@ -129,11 +135,13 @@ def cursor_follow_update(self,context):
|
|||||||
|
|
||||||
def cursor_follow(scene):
|
def cursor_follow(scene):
|
||||||
'''Handler to make the cursor follow active object matrix changes on frame change'''
|
'''Handler to make the cursor follow active object matrix changes on frame change'''
|
||||||
## TODO update global prev_matrix to equal current_matrix on selection change (need another handler)...
|
ob = bpy.context.object
|
||||||
if not bpy.context.object:
|
if bpy.context.scene.gptoolprops.cursor_follow_target:
|
||||||
|
## override with target object is specified
|
||||||
|
ob = bpy.context.scene.gptoolprops.cursor_follow_target
|
||||||
|
if not ob:
|
||||||
return
|
return
|
||||||
global prev_matrix
|
global prev_matrix
|
||||||
ob = bpy.context.object
|
|
||||||
current_matrix = ob.matrix_world
|
current_matrix = ob.matrix_world
|
||||||
if not prev_matrix:
|
if not prev_matrix:
|
||||||
prev_matrix = current_matrix.copy()
|
prev_matrix = current_matrix.copy()
|
||||||
@ -147,8 +155,6 @@ def cursor_follow(scene):
|
|||||||
## translation only
|
## translation only
|
||||||
# scene.cursor.location += (current_matrix - prev_matrix).to_translation()
|
# scene.cursor.location += (current_matrix - prev_matrix).to_translation()
|
||||||
|
|
||||||
# print('offset:', (current_matrix - prev_matrix).to_translation())
|
|
||||||
|
|
||||||
## full
|
## full
|
||||||
scene.cursor.location = current_matrix @ (prev_matrix.inverted() @ scene.cursor.location)
|
scene.cursor.location = current_matrix @ (prev_matrix.inverted() @ scene.cursor.location)
|
||||||
|
|
||||||
@ -156,6 +162,38 @@ def cursor_follow(scene):
|
|||||||
prev_matrix = current_matrix.copy()
|
prev_matrix = current_matrix.copy()
|
||||||
|
|
||||||
|
|
||||||
|
prev_active_obj = None
|
||||||
|
|
||||||
|
## Add check for object selection change
|
||||||
|
def selection_changed():
|
||||||
|
"""Callback function for selection changes"""
|
||||||
|
if not bpy.context.scene.gptoolprops.cursor_follow:
|
||||||
|
return
|
||||||
|
if bpy.context.scene.gptoolprops.cursor_follow_target:
|
||||||
|
# we are following a target, nothing to update on selection change
|
||||||
|
return
|
||||||
|
global prev_matrix, prev_active_obj
|
||||||
|
if prev_active_obj != bpy.context.object:
|
||||||
|
## Set stored matrix to active object
|
||||||
|
prev_matrix = bpy.context.object.matrix_world.copy()
|
||||||
|
prev_active_obj = bpy.context.object
|
||||||
|
|
||||||
|
## Note: Same owner as layer manager (will be removed as well)
|
||||||
|
def subscribe_object_change():
|
||||||
|
subscribe_to = (bpy.types.LayerObjects, 'active')
|
||||||
|
bpy.msgbus.subscribe_rna(
|
||||||
|
key=subscribe_to,
|
||||||
|
# owner of msgbus subcribe (for clearing later)
|
||||||
|
owner=bpy.types.GreasePencil, # <-- attach to ID during it's lifetime.
|
||||||
|
args=(),
|
||||||
|
notify=selection_changed,
|
||||||
|
options={'PERSISTENT'},
|
||||||
|
)
|
||||||
|
|
||||||
|
@persistent
|
||||||
|
def subscribe_object_change_handler(dummy):
|
||||||
|
subscribe_object_change()
|
||||||
|
|
||||||
classes = (
|
classes = (
|
||||||
GPTB_OT_cusor_snap,
|
GPTB_OT_cusor_snap,
|
||||||
)
|
)
|
||||||
@ -163,14 +201,18 @@ GPTB_OT_cusor_snap,
|
|||||||
def register():
|
def register():
|
||||||
for cls in classes:
|
for cls in classes:
|
||||||
bpy.utils.register_class(cls)
|
bpy.utils.register_class(cls)
|
||||||
|
|
||||||
# swap_keymap_by_id('view3d.cursor3d','view3d.cursor_snap')#auto swap to custom GP snap wrap
|
# swap_keymap_by_id('view3d.cursor3d','view3d.cursor_snap')#auto swap to custom GP snap wrap
|
||||||
|
|
||||||
# bpy.app.handlers.frame_change_post.append(cursor_follow)
|
## Follow cursor matrix update on object change
|
||||||
|
bpy.app.handlers.load_post.append(subscribe_object_change_handler) # select_change
|
||||||
|
## Directly set msgbus to work at first addon activation # select_change
|
||||||
|
bpy.app.timers.register(subscribe_object_change, first_interval=1) # select_change
|
||||||
|
|
||||||
|
## No need to frame_change_post.append(cursor_follow). Added by property update, when activating 'cursor follow'
|
||||||
|
|
||||||
|
|
||||||
def unregister():
|
def unregister():
|
||||||
# bpy.app.handlers.frame_change_post.remove(cursor_follow)
|
bpy.app.handlers.load_post.remove(subscribe_object_change_handler) # select_change
|
||||||
|
|
||||||
# swap_keymap_by_id('view3d.cursor_snap','view3d.cursor3d')#Restore normal snap
|
# swap_keymap_by_id('view3d.cursor_snap','view3d.cursor3d')#Restore normal snap
|
||||||
|
|
||||||
@ -180,3 +222,5 @@ def unregister():
|
|||||||
# force remove handler if it's there at unregister
|
# force remove handler if it's there at unregister
|
||||||
if cursor_follow.__name__ in [hand.__name__ for hand in bpy.app.handlers.frame_change_post]:
|
if cursor_follow.__name__ in [hand.__name__ for hand in bpy.app.handlers.frame_change_post]:
|
||||||
bpy.app.handlers.frame_change_post.remove(cursor_follow)
|
bpy.app.handlers.frame_change_post.remove(cursor_follow)
|
||||||
|
|
||||||
|
bpy.msgbus.clear_by_owner(bpy.types.GreasePencil)
|
@ -4,6 +4,11 @@ from pathlib import Path
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
from . import utils
|
from . import utils
|
||||||
|
|
||||||
|
from bpy.props import (BoolProperty,
|
||||||
|
PointerProperty,
|
||||||
|
CollectionProperty,
|
||||||
|
StringProperty)
|
||||||
|
|
||||||
def remove_stroke_exact_duplications(apply=True):
|
def remove_stroke_exact_duplications(apply=True):
|
||||||
'''Remove accidental stroke duplication (points exactly in the same place)
|
'''Remove accidental stroke duplication (points exactly in the same place)
|
||||||
:apply: Remove the duplication instead of just listing dupes
|
:apply: Remove the duplication instead of just listing dupes
|
||||||
@ -53,6 +58,10 @@ class GPTB_OT_file_checker(bpy.types.Operator):
|
|||||||
# Disable use light on all object
|
# Disable use light on all object
|
||||||
# Remove redundant strokes in frames
|
# Remove redundant strokes in frames
|
||||||
|
|
||||||
|
apply_fixes : bpy.props.BoolProperty(name="Apply Fixes", default=False,
|
||||||
|
description="Apply possible fixes instead of just listing (pop the list again in fix mode)",
|
||||||
|
options={'SKIP_SAVE'})
|
||||||
|
|
||||||
def invoke(self, context, event):
|
def invoke(self, context, event):
|
||||||
# need some self-control (I had to...)
|
# need some self-control (I had to...)
|
||||||
self.ctrl = event.ctrl
|
self.ctrl = event.ctrl
|
||||||
@ -63,10 +72,14 @@ class GPTB_OT_file_checker(bpy.types.Operator):
|
|||||||
fix = prefs.fixprops
|
fix = prefs.fixprops
|
||||||
problems = []
|
problems = []
|
||||||
|
|
||||||
apply = not fix.check_only
|
## Old method : Apply fixes based on pref (inverted by ctrl key)
|
||||||
|
# apply = not fix.check_only
|
||||||
|
# # If Ctrl is pressed, invert behavior (invert boolean)
|
||||||
|
# apply ^= self.ctrl
|
||||||
|
|
||||||
# If Ctrl is pressed, invert behavior (invert boolean)
|
apply = self.apply_fixes
|
||||||
apply ^= self.ctrl
|
if self.ctrl:
|
||||||
|
apply = True
|
||||||
|
|
||||||
## Lock main cam:
|
## Lock main cam:
|
||||||
if fix.lock_main_cam:
|
if fix.lock_main_cam:
|
||||||
@ -169,13 +182,14 @@ class GPTB_OT_file_checker(bpy.types.Operator):
|
|||||||
if fix.list_obj_vis_conflict:
|
if fix.list_obj_vis_conflict:
|
||||||
viz_ct = 0
|
viz_ct = 0
|
||||||
for o in context.scene.objects:
|
for o in context.scene.objects:
|
||||||
if o.hide_viewport != o.hide_render:
|
if not (o.hide_get() == o.hide_viewport == o.hide_render):
|
||||||
|
hv = 'No' if o.hide_get() else 'Yes'
|
||||||
vp = 'No' if o.hide_viewport else 'Yes'
|
vp = 'No' if o.hide_viewport else 'Yes'
|
||||||
rd = 'No' if o.hide_render else 'Yes'
|
rd = 'No' if o.hide_render else 'Yes'
|
||||||
viz_ct += 1
|
viz_ct += 1
|
||||||
print(f'{o.name} : viewport {vp} != render {rd}')
|
print(f'{o.name} : viewlayer {hv} - viewport {vp} - render {rd}')
|
||||||
if viz_ct:
|
if viz_ct:
|
||||||
problems.append(['gp.list_object_visibility', f'{viz_ct} objects visibility conflicts (details in console)', 'OBJECT_DATAMODE'])
|
problems.append(['gp.list_object_visibility_conflicts', f'{viz_ct} objects visibility conflicts (details in console)', 'OBJECT_DATAMODE'])
|
||||||
|
|
||||||
## GP modifiers visibility conflict
|
## GP modifiers visibility conflict
|
||||||
if fix.list_gp_mod_vis_conflict:
|
if fix.list_gp_mod_vis_conflict:
|
||||||
@ -289,8 +303,12 @@ class GPTB_OT_file_checker(bpy.types.Operator):
|
|||||||
else:
|
else:
|
||||||
print(p[0])
|
print(p[0])
|
||||||
|
|
||||||
|
if not self.apply_fixes:
|
||||||
|
## button to call the operator again with apply_fixes set to True
|
||||||
|
problems.append(['OPERATOR', 'gp.file_checker', 'Apply Fixes', 'FORWARD', {'apply_fixes': True}])
|
||||||
|
|
||||||
# Show in viewport
|
# Show in viewport
|
||||||
title = "Changed Settings" if apply else "Checked Settings (dry run, nothing changed)"
|
title = "Changed Settings" if apply else "Checked Settings (nothing changed)"
|
||||||
utils.show_message_box(problems, _title = title, _icon = 'INFO')
|
utils.show_message_box(problems, _title = title, _icon = 'INFO')
|
||||||
else:
|
else:
|
||||||
self.report({'INFO'}, 'All good')
|
self.report({'INFO'}, 'All good')
|
||||||
@ -489,46 +507,9 @@ class GPTB_OT_links_checker(bpy.types.Operator):
|
|||||||
self.proj = os.environ.get('PROJECT_ROOT')
|
self.proj = os.environ.get('PROJECT_ROOT')
|
||||||
return context.window_manager.invoke_props_dialog(self, width=popup_width)
|
return context.window_manager.invoke_props_dialog(self, width=popup_width)
|
||||||
|
|
||||||
|
class GPTB_OT_list_viewport_render_visibility(bpy.types.Operator):
|
||||||
""" OLD links checker with show_message_box
|
bl_idname = "gp.list_viewport_render_visibility"
|
||||||
class GPTB_OT_links_checker(bpy.types.Operator):
|
bl_label = "List Viewport And Render Visibility Conflicts"
|
||||||
bl_idname = "gp.links_checker"
|
|
||||||
bl_label = "Links check"
|
|
||||||
bl_description = "Check states of file direct links"
|
|
||||||
bl_options = {"REGISTER"}
|
|
||||||
|
|
||||||
def execute(self, context):
|
|
||||||
all_lnks = []
|
|
||||||
has_broken_link = False
|
|
||||||
## check for broken links
|
|
||||||
for current, lib in zip(bpy.utils.blend_paths(local=True), bpy.utils.blend_paths(absolute=True, local=True)):
|
|
||||||
lfp = Path(lib)
|
|
||||||
realib = Path(current)
|
|
||||||
if not lfp.exists():
|
|
||||||
has_broken_link = True
|
|
||||||
all_lnks.append( (f"Broken link: {realib.as_posix()}", 'LIBRARY_DATA_BROKEN') )#lfp.as_posix()
|
|
||||||
else:
|
|
||||||
if realib.as_posix().startswith('//'):
|
|
||||||
all_lnks.append( (f"Link: {realib.as_posix()}", 'LINKED') )#lfp.as_posix()
|
|
||||||
else:
|
|
||||||
all_lnks.append( (f"Link: {realib.as_posix()}", 'LIBRARY_DATA_INDIRECT') )#lfp.as_posix()
|
|
||||||
|
|
||||||
all_lnks.sort(key=lambda x: x[1], reverse=True)
|
|
||||||
if all_lnks:
|
|
||||||
print('===File check===')
|
|
||||||
for p in all_lnks:
|
|
||||||
if isinstance(p, str):
|
|
||||||
print(p)
|
|
||||||
else:
|
|
||||||
print(p[0])
|
|
||||||
# Show in viewport
|
|
||||||
utils.show_message_box(all_lnks, _title = "Links", _icon = 'INFO')
|
|
||||||
return {"FINISHED"} """
|
|
||||||
|
|
||||||
|
|
||||||
class GPTB_OT_list_object_visibility(bpy.types.Operator):
|
|
||||||
bl_idname = "gp.list_object_visibility"
|
|
||||||
bl_label = "List Object Visibility Conflicts"
|
|
||||||
bl_description = "List objects visibility conflicts, when viewport and render have different values"
|
bl_description = "List objects visibility conflicts, when viewport and render have different values"
|
||||||
bl_options = {"REGISTER"}
|
bl_options = {"REGISTER"}
|
||||||
|
|
||||||
@ -547,60 +528,221 @@ class GPTB_OT_list_object_visibility(bpy.types.Operator):
|
|||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
## basic listing as message box # all in invoke now
|
|
||||||
# li = []
|
|
||||||
# viz_ct = 0
|
|
||||||
# for o in context.scene.objects:
|
|
||||||
# if o.hide_viewport != o.hide_render:
|
|
||||||
# vp = 'No' if o.hide_viewport else 'Yes'
|
|
||||||
# rd = 'No' if o.hide_render else 'Yes'
|
|
||||||
# viz_ct += 1
|
|
||||||
# li.append(f'{o.name} : viewport {vp} != render {rd}')
|
|
||||||
# if li:
|
|
||||||
# utils.show_message_box(_message=li, _title=f'{viz_ct} visibility conflicts found')
|
|
||||||
# else:
|
|
||||||
# self.report({'INFO'}, f"No Object visibility conflict on current scene")
|
|
||||||
# return {'FINISHED'}
|
|
||||||
|
|
||||||
|
### -- Sync visibility ops (Could be fused in one ops, but having 3 different operators allow to call from search menu)
|
||||||
|
class GPTB_OT_sync_visibility_from_viewlayer(bpy.types.Operator):
|
||||||
|
bl_idname = "gp.sync_visibility_from_viewlayer"
|
||||||
|
bl_label = "Sync Visibility From Viewlayer"
|
||||||
|
bl_description = "Set viewport and render visibility to match viewlayer visibility"
|
||||||
|
bl_options = {"REGISTER", "UNDO"}
|
||||||
|
|
||||||
## Only GP modifier
|
def execute(self, context):
|
||||||
'''
|
for obj in context.scene.objects:
|
||||||
class GPTB_OT_list_modifier_visibility(bpy.types.Operator):
|
is_hidden = obj.hide_get() # Get viewlayer visibility
|
||||||
bl_idname = "gp.list_modifier_visibility"
|
obj.hide_viewport = is_hidden
|
||||||
bl_label = "List GP Modifiers Visibility Conflicts"
|
obj.hide_render = is_hidden
|
||||||
bl_description = "List Modifier visibility conflicts, when viewport and render have different values"
|
return {'FINISHED'}
|
||||||
|
|
||||||
|
class GPTB_OT_sync_visibility_from_viewport(bpy.types.Operator):
|
||||||
|
bl_idname = "gp.sync_visibility_from_viewport"
|
||||||
|
bl_label = "Sync Visibility From Viewport"
|
||||||
|
bl_description = "Set viewlayer and render visibility to match viewport visibility"
|
||||||
|
bl_options = {"REGISTER", "UNDO"}
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
for obj in context.scene.objects:
|
||||||
|
is_hidden = obj.hide_viewport
|
||||||
|
obj.hide_set(is_hidden)
|
||||||
|
obj.hide_render = is_hidden
|
||||||
|
return {'FINISHED'}
|
||||||
|
|
||||||
|
class GPTB_OT_sync_visibility_from_render(bpy.types.Operator):
|
||||||
|
bl_idname = "gp.sync_visibility_from_render"
|
||||||
|
bl_label = "Sync Visibility From Render"
|
||||||
|
bl_description = "Set viewlayer and viewport visibility to match render visibility"
|
||||||
|
bl_options = {"REGISTER", "UNDO"}
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
for obj in context.scene.objects:
|
||||||
|
is_hidden = obj.hide_render
|
||||||
|
obj.hide_set(is_hidden)
|
||||||
|
obj.hide_viewport = is_hidden
|
||||||
|
return {'FINISHED'}
|
||||||
|
|
||||||
|
class GPTB_OT_sync_visibible_to_render(bpy.types.Operator):
|
||||||
|
bl_idname = "gp.sync_visibible_to_render"
|
||||||
|
bl_label = "Sync Overall Viewport Visibility To Render"
|
||||||
|
bl_description = "Set render visibility from"
|
||||||
|
bl_options = {"REGISTER", "UNDO"}
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
for obj in context.scene.objects:
|
||||||
|
## visible_get is the current visibility status combination of hide_viewport and viewlayer hide (eye)
|
||||||
|
obj.hide_render = not obj.visible_get()
|
||||||
|
return {'FINISHED'}
|
||||||
|
|
||||||
|
class GPTB_PG_object_visibility(bpy.types.PropertyGroup):
|
||||||
|
"""Property group to handle object visibility"""
|
||||||
|
is_hidden: BoolProperty(
|
||||||
|
name="Hide in Viewport",
|
||||||
|
description="Toggle object visibility in viewport",
|
||||||
|
get=lambda self: self.get("is_hidden", False),
|
||||||
|
set=lambda self, value: self.set_visibility(value)
|
||||||
|
)
|
||||||
|
|
||||||
|
object_name: StringProperty(name="Object Name")
|
||||||
|
|
||||||
|
def set_visibility(self, value):
|
||||||
|
"""Set the visibility using hide_set()"""
|
||||||
|
obj = bpy.context.view_layer.objects.get(self.object_name)
|
||||||
|
if obj:
|
||||||
|
obj.hide_set(value)
|
||||||
|
self["is_hidden"] = value
|
||||||
|
|
||||||
|
class GPTB_OT_list_object_visibility_conflicts(bpy.types.Operator):
|
||||||
|
bl_idname = "gp.list_object_visibility_conflicts"
|
||||||
|
bl_label = "List Object Visibility Conflicts"
|
||||||
|
bl_description = "List objects visibility conflicts, when viewport and render have different values"
|
||||||
bl_options = {"REGISTER"}
|
bl_options = {"REGISTER"}
|
||||||
|
|
||||||
def invoke(self, context, event):
|
visibility_items: CollectionProperty(type=GPTB_PG_object_visibility) # type: ignore[valid-type]
|
||||||
self.ob_list = []
|
|
||||||
for o in context.scene.objects:
|
## options:
|
||||||
if o.type != 'GPENCIL':
|
# check_viewlayer : BoolProperty(name="Check Viewlayer", default=False, description="Compare viewlayer (eye) visibility")
|
||||||
continue
|
# check_viewport : BoolProperty(name="Check Viewport", default=False, description="Compare Viewport (screen icon) visibility")
|
||||||
if not len(o.grease_pencil_modifiers):
|
# check_render : BoolProperty(name="Check Viewport", default=False, description="Compare Render visibility")
|
||||||
continue
|
|
||||||
|
def invoke(self, context, event):
|
||||||
|
# Clear and rebuild both collections
|
||||||
|
self.visibility_items.clear()
|
||||||
|
|
||||||
|
# Store objects with conflicts
|
||||||
|
objects_with_conflicts = [o for o in context.scene.objects if not (o.hide_get() == o.hide_viewport == o.hide_render)]
|
||||||
|
|
||||||
|
|
||||||
|
# Create visibility items
|
||||||
|
for obj in objects_with_conflicts:
|
||||||
|
item = self.visibility_items.add()
|
||||||
|
item.object_name = obj.name
|
||||||
|
item["is_hidden"] = obj.hide_get()
|
||||||
|
|
||||||
mods = []
|
|
||||||
for m in o.grease_pencil_modifiers:
|
|
||||||
if m.show_viewport != m.show_render:
|
|
||||||
if not mods:
|
|
||||||
self.ob_list.append([o, mods])
|
|
||||||
mods.append(m)
|
|
||||||
return context.window_manager.invoke_props_dialog(self, width=250)
|
return context.window_manager.invoke_props_dialog(self, width=250)
|
||||||
|
|
||||||
def draw(self, context):
|
def draw(self, context):
|
||||||
layout = self.layout
|
layout = self.layout
|
||||||
for o in self.ob_list:
|
# row.prop(self, "check_viewlayer")
|
||||||
layout.label(text=o[0].name, icon='OUTLINER_OB_GREASEPENCIL')
|
# row.prop(self, "check_viewport")
|
||||||
for m in o[1]:
|
# row.prop(self, "check_render")
|
||||||
row = layout.row()
|
## If filtered by prop, displayed list will resize while applying changes ! (not good)
|
||||||
row.label(text='')
|
|
||||||
row.label(text=m.name, icon='MODIFIER_ON')
|
# Add sync buttons at the top
|
||||||
row.prop(m, 'show_viewport', text='', emboss=False) # invert_checkbox=True
|
row = layout.row(align=False)
|
||||||
row.prop(m, 'show_render', text='', emboss=False) # invert_checkbox=True
|
row.label(text="Sync All Visibility From:")
|
||||||
|
row.operator("gp.sync_visibility_from_viewlayer", text="", icon='HIDE_OFF')
|
||||||
|
row.operator("gp.sync_visibility_from_viewport", text="", icon='RESTRICT_VIEW_OFF')
|
||||||
|
row.operator("gp.sync_visibility_from_render", text="", icon='RESTRICT_RENDER_OFF')
|
||||||
|
layout.separator()
|
||||||
|
|
||||||
|
col = layout.column()
|
||||||
|
# We can safely iterate over visibility_items since objects are stored in same order
|
||||||
|
for vis_item in self.visibility_items:
|
||||||
|
obj = context.view_layer.objects.get(vis_item.object_name)
|
||||||
|
if not obj:
|
||||||
|
continue
|
||||||
|
|
||||||
|
row = col.row(align=False)
|
||||||
|
row.label(text=obj.name)
|
||||||
|
|
||||||
|
## Viewlayer visibility "as prop" to allow slide toggle
|
||||||
|
# hide_icon='HIDE_ON' if vis_item.is_hidden else 'HIDE_OFF'
|
||||||
|
hide_icon='HIDE_ON' if obj.hide_get() else 'HIDE_OFF'
|
||||||
|
row.prop(vis_item, "is_hidden", text="", icon=hide_icon, emboss=False)
|
||||||
|
|
||||||
|
# Direct object properties
|
||||||
|
row.prop(obj, 'hide_viewport', text='', emboss=False)
|
||||||
|
row.prop(obj, 'hide_render', text='', emboss=False)
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
return {'FINISHED'}
|
||||||
|
|
||||||
|
def get_collection_children_recursive(col, cols=None) -> list:
|
||||||
|
'''return a list of all the child collections
|
||||||
|
and their subcollections in the passed collection'''
|
||||||
|
|
||||||
|
cols = cols or []
|
||||||
|
for sub in col.children:
|
||||||
|
if sub not in cols:
|
||||||
|
cols.append(sub)
|
||||||
|
if len(sub.children):
|
||||||
|
cols = get_collection_children_recursive(sub, cols)
|
||||||
|
return cols
|
||||||
|
|
||||||
|
class GPTB_OT_list_collection_visibility_conflicts(bpy.types.Operator):
|
||||||
|
bl_idname = "gp.list_collection_visibility_conflicts"
|
||||||
|
bl_label = "List Collection Visibility Conflicts"
|
||||||
|
bl_description = "List collection visibility conflicts, when viewport and render have different values"
|
||||||
|
bl_options = {"REGISTER"}
|
||||||
|
|
||||||
|
# visibility_items: CollectionProperty(type=GPTB_PG_collection_visibility)
|
||||||
|
show_filter : bpy.props.EnumProperty(
|
||||||
|
name="View Filter",
|
||||||
|
description="Filter collections based on their exclusion status",
|
||||||
|
items=(
|
||||||
|
('ALL', "All", "Show all collections", 0),
|
||||||
|
('NOT_EXCLUDED', "Not Excluded", "Show collections that are not excluded", 1),
|
||||||
|
('EXCLUDED', "Excluded", "Show collections that are excluded", 2)
|
||||||
|
),
|
||||||
|
default='NOT_EXCLUDED')
|
||||||
|
|
||||||
|
def invoke(self, context, event):
|
||||||
|
## get all viewlayer collections
|
||||||
|
vcols = get_collection_children_recursive(context.view_layer.layer_collection)
|
||||||
|
vcols = list(set(vcols)) # ensure no duplicates
|
||||||
|
|
||||||
|
## Store collection with conflicts
|
||||||
|
# layer_collection.is_visible against render visibility ?
|
||||||
|
## Do not list currently excluded collections
|
||||||
|
self.conflict_collections = [vc for vc in vcols if not (vc.hide_viewport == vc.collection.hide_viewport == vc.collection.hide_render)]
|
||||||
|
self.included_collection = [vc for vc in self.conflict_collections if not vc.exclude]
|
||||||
|
self.excluded_collection = [vc for vc in self.conflict_collections if vc.exclude]
|
||||||
|
|
||||||
|
return context.window_manager.invoke_props_dialog(self, width=250)
|
||||||
|
|
||||||
|
def draw(self, context):
|
||||||
|
layout = self.layout
|
||||||
|
layout.prop(self, 'show_filter', expand=True)
|
||||||
|
|
||||||
|
# Add sync buttons at the top
|
||||||
|
row = layout.row(align=False)
|
||||||
|
# TODO: Add "set all from" ops on collection (optionnal)
|
||||||
|
# row.label(text="Sync All Visibility From:")
|
||||||
|
# row.operator("gp.sync_visibility_from_viewlayer", text="", icon='HIDE_OFF')
|
||||||
|
# row.operator("gp.sync_visibility_from_viewport", text="", icon='RESTRICT_VIEW_OFF')
|
||||||
|
# row.operator("gp.sync_visibility_from_render", text="", icon='RESTRICT_RENDER_OFF')
|
||||||
|
layout.separator()
|
||||||
|
|
||||||
|
if self.show_filter == 'ALL':
|
||||||
|
vl_collections = self.conflict_collections
|
||||||
|
elif self.show_filter == 'EXCLUDED':
|
||||||
|
vl_collections = self.excluded_collection
|
||||||
|
elif self.show_filter == 'NOT_EXCLUDED':
|
||||||
|
vl_collections = self.included_collection
|
||||||
|
|
||||||
|
col = layout.column()
|
||||||
|
for vlcol in vl_collections:
|
||||||
|
row = col.row(align=False)
|
||||||
|
row.label(text=vlcol.name)
|
||||||
|
|
||||||
|
# Viewlayer collection settings
|
||||||
|
row.prop(vlcol, "exclude", text="", emboss=False)
|
||||||
|
row.prop(vlcol, "hide_viewport", text="", emboss=False)
|
||||||
|
|
||||||
|
# Direct collection properties
|
||||||
|
row.prop(vlcol.collection, 'hide_viewport', text='', emboss=False)
|
||||||
|
row.prop(vlcol.collection, 'hide_render', text='', emboss=False)
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
'''
|
|
||||||
|
|
||||||
## not exposed in UI, Check is performed in Check file (can be called in popped menu)
|
## not exposed in UI, Check is performed in Check file (can be called in popped menu)
|
||||||
class GPTB_OT_list_modifier_visibility(bpy.types.Operator):
|
class GPTB_OT_list_modifier_visibility(bpy.types.Operator):
|
||||||
@ -652,7 +794,14 @@ class GPTB_OT_list_modifier_visibility(bpy.types.Operator):
|
|||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
|
|
||||||
classes = (
|
classes = (
|
||||||
GPTB_OT_list_object_visibility,
|
GPTB_OT_list_viewport_render_visibility, # Only viewport and render
|
||||||
|
GPTB_OT_sync_visibility_from_viewlayer,
|
||||||
|
GPTB_OT_sync_visibility_from_viewport,
|
||||||
|
GPTB_OT_sync_visibility_from_render,
|
||||||
|
GPTB_OT_sync_visibible_to_render,
|
||||||
|
GPTB_PG_object_visibility,
|
||||||
|
GPTB_OT_list_object_visibility_conflicts,
|
||||||
|
GPTB_OT_list_collection_visibility_conflicts,
|
||||||
GPTB_OT_list_modifier_visibility,
|
GPTB_OT_list_modifier_visibility,
|
||||||
GPTB_OT_copy_string_to_clipboard,
|
GPTB_OT_copy_string_to_clipboard,
|
||||||
GPTB_OT_copy_multipath_clipboard,
|
GPTB_OT_copy_multipath_clipboard,
|
||||||
|
@ -279,7 +279,8 @@ class GPTB_PT_anim_manager(Panel):
|
|||||||
col.use_property_split = False
|
col.use_property_split = False
|
||||||
text, icon = ('Cursor Follow On', 'PIVOT_CURSOR') if context.scene.gptoolprops.cursor_follow else ('Cursor Follow Off', 'CURSOR')
|
text, icon = ('Cursor Follow On', 'PIVOT_CURSOR') if context.scene.gptoolprops.cursor_follow else ('Cursor Follow Off', 'CURSOR')
|
||||||
col.prop(context.scene.gptoolprops, 'cursor_follow', text=text, icon=icon)
|
col.prop(context.scene.gptoolprops, 'cursor_follow', text=text, icon=icon)
|
||||||
|
if context.scene.gptoolprops.cursor_follow:
|
||||||
|
col.prop(context.scene.gptoolprops, 'cursor_follow_target', text='Target', icon='OBJECT_DATA')
|
||||||
|
|
||||||
class GPTB_PT_toolbox_playblast(Panel):
|
class GPTB_PT_toolbox_playblast(Panel):
|
||||||
bl_label = "Playblast"
|
bl_label = "Playblast"
|
||||||
|
15
__init__.py
15
__init__.py
@ -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, 3, 0),
|
"version": (3, 3, 5),
|
||||||
"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": "",
|
||||||
@ -625,9 +625,8 @@ class GPTB_prefs(bpy.types.AddonPreferences):
|
|||||||
layout.label(text='Following checks will be made when clicking "Check File" button:')
|
layout.label(text='Following checks will be made when clicking "Check File" button:')
|
||||||
col = layout.column()
|
col = layout.column()
|
||||||
col.use_property_split = True
|
col.use_property_split = True
|
||||||
col.prop(self.fixprops, 'check_only')
|
col.label(text='The popup list possible fixes, you can then use "Apply Fixes"', icon='INFO')
|
||||||
col.label(text='If dry run is checked, no modification is done', icon='INFO')
|
# col.label(text='(preferences for tool changes are directly applied)', icon='BLANK1')
|
||||||
col.label(text='Use Ctrl + Click on "Check File" button to invert the behavior', icon='BLANK1')
|
|
||||||
col.separator()
|
col.separator()
|
||||||
col.prop(self.fixprops, 'lock_main_cam')
|
col.prop(self.fixprops, 'lock_main_cam')
|
||||||
col.prop(self.fixprops, 'set_scene_res', text=f'Reset Scene Resolution (to {self.render_res_x}x{self.render_res_y})')
|
col.prop(self.fixprops, 'set_scene_res', text=f'Reset Scene Resolution (to {self.render_res_x}x{self.render_res_y})')
|
||||||
@ -813,6 +812,10 @@ addon_modules = (
|
|||||||
)
|
)
|
||||||
|
|
||||||
def register():
|
def register():
|
||||||
|
if bpy.app.version >= (4, 3, 0):
|
||||||
|
print(f"Skip GP toolbox load, version {'.'.join([str(x) for x in bl_info['version']])} incompatible with Blender 4.3+")
|
||||||
|
return
|
||||||
|
|
||||||
# Register property group first
|
# Register property group first
|
||||||
properties.register()
|
properties.register()
|
||||||
for cls in classes:
|
for cls in classes:
|
||||||
@ -838,6 +841,10 @@ def register():
|
|||||||
|
|
||||||
|
|
||||||
def unregister():
|
def unregister():
|
||||||
|
if bpy.app.version >= (4, 3, 0):
|
||||||
|
# print(f'GP Toolbox version is not compatible with Blender 4.3+')
|
||||||
|
return
|
||||||
|
|
||||||
if 'remap_relative' in [hand.__name__ for hand in bpy.app.handlers.save_pre]:
|
if 'remap_relative' in [hand.__name__ for hand in bpy.app.handlers.save_pre]:
|
||||||
bpy.app.handlers.save_pre.remove(remap_relative)
|
bpy.app.handlers.save_pre.remove(remap_relative)
|
||||||
|
|
||||||
|
@ -31,11 +31,6 @@ def update_layer_name(self, context):
|
|||||||
|
|
||||||
class GP_PG_FixSettings(PropertyGroup):
|
class GP_PG_FixSettings(PropertyGroup):
|
||||||
|
|
||||||
check_only : BoolProperty(
|
|
||||||
name="Dry run mode (Check only)",
|
|
||||||
description="Do not change anything, just print the messages",
|
|
||||||
default=False, options={'HIDDEN'})
|
|
||||||
|
|
||||||
lock_main_cam : BoolProperty(
|
lock_main_cam : BoolProperty(
|
||||||
name="Lock Main Cam",
|
name="Lock Main Cam",
|
||||||
description="Lock the main camera (works only if 'layout' is not in name)",
|
description="Lock the main camera (works only if 'layout' is not in name)",
|
||||||
@ -182,6 +177,11 @@ class GP_PG_ToolsSettings(PropertyGroup):
|
|||||||
name='Cursor Follow', description="3D cursor follow active object animation when activated",
|
name='Cursor Follow', description="3D cursor follow active object animation when activated",
|
||||||
default=False, update=cursor_follow_update)
|
default=False, update=cursor_follow_update)
|
||||||
|
|
||||||
|
cursor_follow_target : bpy.props.PointerProperty(
|
||||||
|
name='Cursor Follow Target',
|
||||||
|
description="Optional target object to follow for cursor instead of active object",
|
||||||
|
type=bpy.types.Object, update=cursor_follow_update)
|
||||||
|
|
||||||
edit_lines_opacity : FloatProperty(
|
edit_lines_opacity : FloatProperty(
|
||||||
name="Edit Lines Opacity", description="Change edit lines opacity for all grease pencils",
|
name="Edit Lines Opacity", description="Change edit lines opacity for all grease pencils",
|
||||||
default=0.5, min=0.0, max=1.0, step=3, precision=2, update=change_edit_lines_opacity)
|
default=0.5, min=0.0, max=1.0, step=3, precision=2, update=change_edit_lines_opacity)
|
||||||
|
33
utils.py
33
utils.py
@ -823,28 +823,37 @@ def convert_attr(Attr):
|
|||||||
def show_message_box(_message = "", _title = "Message Box", _icon = 'INFO'):
|
def show_message_box(_message = "", _title = "Message Box", _icon = 'INFO'):
|
||||||
'''Show message box with element passed as string or list
|
'''Show message box with element passed as string or list
|
||||||
if _message if a list of lists:
|
if _message if a list of lists:
|
||||||
|
if first element is "OPERATOR":
|
||||||
|
List format: ["OPERATOR", operator_id, text, icon, {prop_name: value, ...}]
|
||||||
if sublist have 2 element:
|
if sublist have 2 element:
|
||||||
considered a label [text, icon]
|
considered a label [text, icon]
|
||||||
if sublist have 3 element:
|
if sublist have 3 element:
|
||||||
considered as an operator [ops_id_name, text, icon]
|
considered as an operator [ops_id_name, text, icon]
|
||||||
|
if sublist have 4 element:
|
||||||
|
considered as a property [object, propname, text, icon]
|
||||||
'''
|
'''
|
||||||
|
|
||||||
def draw(self, context):
|
def draw(self, context):
|
||||||
|
layout = self.layout
|
||||||
for l in _message:
|
for l in _message:
|
||||||
if isinstance(l, str):
|
if isinstance(l, str):
|
||||||
self.layout.label(text=l)
|
layout.label(text=l)
|
||||||
else:
|
elif l[0] == "OPERATOR": # Special operator case with properties
|
||||||
if len(l) == 2: # label with icon
|
layout.operator_context = "INVOKE_DEFAULT"
|
||||||
self.layout.label(text=l[0], icon=l[1])
|
op = layout.operator(l[1], text=l[2], icon=l[3], emboss=False)
|
||||||
|
if len(l) > 4 and isinstance(l[4], dict):
|
||||||
|
for prop_name, value in l[4].items():
|
||||||
|
setattr(op, prop_name, value)
|
||||||
|
|
||||||
|
elif len(l) == 2: # label with icon
|
||||||
|
layout.label(text=l[0], icon=l[1])
|
||||||
elif len(l) == 3: # ops
|
elif len(l) == 3: # ops
|
||||||
self.layout.operator_context = "INVOKE_DEFAULT"
|
layout.operator_context = "INVOKE_DEFAULT"
|
||||||
self.layout.operator(l[0], text=l[1], icon=l[2], emboss=False) # <- highligh the entry
|
layout.operator(l[0], text=l[1], icon=l[2], emboss=False) # <- highligh the entry
|
||||||
|
elif len(l) == 4: # prop
|
||||||
## offset pnale when using row...
|
row = layout.row(align=True)
|
||||||
# row = self.layout.row()
|
row.label(text=l[2], icon=l[3])
|
||||||
# row.label(text=l[1])
|
row.prop(l[0], l[1], text='')
|
||||||
# row.operator(l[0], icon=l[2])
|
|
||||||
|
|
||||||
if isinstance(_message, str):
|
if isinstance(_message, str):
|
||||||
_message = [_message]
|
_message = [_message]
|
||||||
bpy.context.window_manager.popup_menu(draw, title = _title, icon = _icon)
|
bpy.context.window_manager.popup_menu(draw, title = _title, icon = _icon)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user