keyframe jump autobind
0.9.3: - feat: keyframe jump keys are now auto-binded - UI: added keyframe jump customisation in addon pref - code: split keyframe jump in a separate file with his new key updater
This commit is contained in:
@@ -32,82 +32,6 @@ class GPTB_OT_flipx_view(bpy.types.Operator):
|
||||
context.scene.camera.scale.x *= -1
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class GPTB_OT_jump_gp_keyframe(bpy.types.Operator):
|
||||
bl_idname = "screen.gp_keyframe_jump"
|
||||
bl_label = "Jump to GPencil keyframe"
|
||||
bl_description = "Jump to prev/next keyframe on active and selected layers of active grease pencil object"
|
||||
bl_options = {"REGISTER"}
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
return context.object and context.object.type == 'GPENCIL'
|
||||
|
||||
next : bpy.props.BoolProperty(
|
||||
name="Next GP keyframe", description="Go to next active GP keyframe", default=True)
|
||||
|
||||
target : bpy.props.EnumProperty(
|
||||
name="Target layer", description="Choose wich layer to evaluate for keyframe change", default='ACTIVE',# options={'ANIMATABLE'}, update=None, get=None, set=None,
|
||||
items=(
|
||||
('ACTIVE', 'Active and selected', 'jump in keyframes of active and other selected layers ', 0),
|
||||
('VISIBLE', 'Visibles layers', 'jump in keyframes of visibles layers', 1),
|
||||
('ACCESSIBLE', 'Visible and unlocked layers', 'jump in keyframe of all layers', 2),
|
||||
))
|
||||
#(key, label, descr, id[, icon])
|
||||
|
||||
def execute(self, context):
|
||||
if not context.object.data.layers.active:
|
||||
self.report({'ERROR'}, 'No active layer on current GPencil object')
|
||||
return {"CANCELLED"}
|
||||
|
||||
layer = []
|
||||
if self.target == 'ACTIVE':
|
||||
gpl = [l for l in context.object.data.layers if l.select and not l.hide]
|
||||
if not context.object.data.layers.active in gpl:
|
||||
gpl.append(context.object.data.layers.active)
|
||||
|
||||
elif self.target == 'VISIBLE':
|
||||
gpl = [l for l in context.object.data.layers if not l.hide]
|
||||
|
||||
elif self.target == 'ACCESSIBLE':
|
||||
gpl = [l for l in context.object.data.layers if not l.hide and not l.lock]
|
||||
|
||||
|
||||
current = context.scene.frame_current
|
||||
p = n = None
|
||||
|
||||
mins = []
|
||||
maxs = []
|
||||
for l in gpl:
|
||||
for f in l.frames:
|
||||
if f.frame_number < current:
|
||||
p = f.frame_number
|
||||
if f.frame_number > current:
|
||||
n = f.frame_number
|
||||
break
|
||||
mins.append(p)
|
||||
maxs.append(n)
|
||||
p = n = None
|
||||
|
||||
mins = [i for i in mins if i is not None]
|
||||
maxs = [i for i in maxs if i is not None]
|
||||
|
||||
if mins:
|
||||
p = max(mins)
|
||||
if maxs:
|
||||
n = min(maxs)
|
||||
|
||||
if self.next and n is not None:
|
||||
context.scene.frame_set(n)
|
||||
elif not self.next and p is not None:
|
||||
context.scene.frame_set(p)
|
||||
else:
|
||||
self.report({'INFO'}, 'No keyframe in this direction')
|
||||
return {"CANCELLED"}
|
||||
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class GPTB_OT_rename_data_from_obj(bpy.types.Operator):
|
||||
bl_idname = "gp.rename_data_from_obj"
|
||||
bl_label = "Rename GP from object"
|
||||
@@ -528,7 +452,6 @@ class GPTB_OT_overlay_presets(bpy.types.Operator):
|
||||
classes = (
|
||||
GPTB_OT_copy_text,
|
||||
GPTB_OT_flipx_view,
|
||||
GPTB_OT_jump_gp_keyframe,
|
||||
GPTB_OT_rename_data_from_obj,
|
||||
GPTB_OT_draw_cam,
|
||||
GPTB_OT_set_view_as_cam,
|
||||
|
||||
Reference in New Issue
Block a user