I want this two script only, not complete tool. simply for assign shortkey. ctrl+alt+arrow are extremely bad shortkeys and useless for me.
thanks friends
rt_next_keyframe
Code: Select all
-- **************************************************
-- Provide Moho with the name of this script object
-- **************************************************
ScriptName = "RT_NextKeyframe"
-- **************************************************
-- General information about this script
-- **************************************************
RT_NextKeyframe = {}
function RT_NextKeyframe:Name()
return "Go to next keyframe"
end
function RT_NextKeyframe:Version()
return "0.1"
end
function RT_NextKeyframe:Description()
return "Go to next keyframe for current layer"
end
function RT_NextKeyframe:Creator()
return "Rudiger"
end
function RT_NextKeyframe:UILabel()
return("Next keyframe")
end
-- **************************************************
-- The guts of this script
-- **************************************************
function RT_NextKeyframe:AllChannelsHasKey(channels, global_channels, start_frame, end_frame, moho)
-- Check whether any channels have keyframe in the given frame range
local doc
local found_key = false
local incr
local layer = moho.layer
local timing_offset
if end_frame > start_frame then
incr = 1
else
incr = -1
end
if layer.TotalTimingOffset ~= nil then
timing_offset = layer:TotalTimingOffset()
else
timing_offset = 0
end
-- Go through next/previous frames and stop when a keyframe is found
for frame = start_frame, end_frame, incr do
for i, channel in ipairs(channels) do
if channel.HasKey ~= nil and channel:HasKey(frame) then
found_key = true
break
end
end
if found_key == false and global_channels ~= nil then
for i, channel in ipairs(global_channels) do
if channel.HasKey ~= nil and channel:HasKey(frame) then
found_key = true
break
end
end
end
if found_key then
moho:SetCurFrame(frame-timing_offset)
break
end
end
return found_key
end
function RT_NextKeyframe:Run(moho)
local layer = moho.layer
local doc
local current_frame
local channels
local channel
local i
local global_channels
if moho.layerFrame ~= nil then
current_frame = moho.layerFrame
else
current_frame = moho.frame
end
-- Modify to only detect point keys
--channels = RT_Utilities:get_point_channels(moho)
-- Get all layer and global channels
channels = RT_Utilities:get_layer_channels(moho, moho.layer)
if layer:CurrentAction() == "" then
global_channels = RT_Utilities:get_global_channels(moho)
end
-- Do it in two stages as running AnimDuration takes a while
local found_key = RT_NextKeyframe:AllChannelsHasKey(channels, global_channels,
current_frame+1, current_frame+20, moho)
if found_key then
return
end
local anim_duration = moho.document:AnimDuration()
RT_NextKeyframe:AllChannelsHasKey(channels, global_channels,
current_frame+21, anim_duration, moho)
-- **ToDo: Figure out how to update Frame indicator
moho:UpdateUI()
end
Code: Select all
-- **************************************************
-- Provide Moho with the name of this script object
-- **************************************************
ScriptName = "RT_PrevKeyframe"
-- **************************************************
-- General information about this script
-- **************************************************
RT_PrevKeyframe = {}
function RT_PrevKeyframe:Name()
return "Go to previous keyframe"
end
function RT_PrevKeyframe:Version()
return "0.1"
end
function RT_PrevKeyframe:Description()
return "Go to previous keyframe for current layer"
end
function RT_PrevKeyframe:Creator()
return "Rudiger"
end
function RT_PrevKeyframe:UILabel()
return("Previous keyframe")
end
-- **************************************************
-- The guts of this script
-- **************************************************
function RT_PrevKeyframe:Run(moho)
local layer = moho.layer
local doc = moho.document
local current_frame
local frame
local channels
local channel
local i
local global_channels
if moho.layerFrame ~= nil then
current_frame = moho.layerFrame
else
current_frame = moho.frame
end
-- Get all layer and global channels
channels = RT_Utilities:get_layer_channels(moho, layer)
if layer:CurrentAction() == "" then
global_channels = RT_Utilities:get_global_channels(moho)
end
-- Check whether there are any keys to the left of the cursor
RT_NextKeyframe:AllChannelsHasKey(channels, global_channels, current_frame-1, 0, moho)
-- **ToDo: Figure out how to update Frame indicator
moho:UpdateUI()
end