Layers Timeline
Moderators: Víctor Paredes, Belgarath, slowtiger
Layers Timeline
Is there a way to bulk enable a selected layers to be show in timeline rather then clicking the check one layer at a time?
~ David McInnis
Re: Layers Timeline
That would be nice, should be incorporated in the quick settings dropdown.
Remember by default you can only see a maximum of 10 layers in the timeline no matter how many you click. You need to use edit->preferences->timeline->max selected layers to change the maximum. I forgot this once and thought every 'stopwatch' box I was ticking was appearing in the time line (ticked about 14 layers), then edited them in the timeline thinking I was editing all of the ticked ones.. messed up my animation before I realised what had happened. It should prevent us from clicking more than the max, or at least show a warning message that the new layers I am clicking are not going to appear.
Remember by default you can only see a maximum of 10 layers in the timeline no matter how many you click. You need to use edit->preferences->timeline->max selected layers to change the maximum. I forgot this once and thought every 'stopwatch' box I was ticking was appearing in the time line (ticked about 14 layers), then edited them in the timeline thinking I was editing all of the ticked ones.. messed up my animation before I realised what had happened. It should prevent us from clicking more than the max, or at least show a warning message that the new layers I am clicking are not going to appear.
- synthsin75
- Posts: 9981
- Joined: Mon Jan 14, 2008 11:20 pm
- Location: Oklahoma
- Contact:
Re: Layers Timeline
Here's an older menu script of mine to toggle timeline visibility for all selected layers: https://drive.google.com/file/d/1OAoRKE ... sp=sharing
And I just updated it to include a warning if the number of selected layers exceeds the "Max selected layers" setting in Moho 13.5.5.
And I just updated it to include a warning if the number of selected layers exceeds the "Max selected layers" setting in Moho 13.5.5.
- Wes
Donations: https://www.paypal.com/paypalme/synthsin75 (Thx, everyone.)
https://www.youtube.com/user/synthsin75
Scripting reference: https://mohoscripting.com/
Donations: https://www.paypal.com/paypalme/synthsin75 (Thx, everyone.)
https://www.youtube.com/user/synthsin75
Scripting reference: https://mohoscripting.com/
Re: Layers Timeline
Haha, I did a script as well - my very first tool script lol.
https://we.tl/t-aRdFXfsDAu
Just pop both files in the Scripts->Tool directory, Ctrl-Shift-Alt-L to reload scripts in Moho, then new stopwatch icon will appear in tools pallet. Select your layers and click on stopwatch to toggle their visibility in timeline.
But I couldn't find the API reference to tell me the 'Maximun Selected Layers' setting. I assumed it would be in MohoGlobals but couldn't find it there. Then I thought since its a recent addition maybe mohoscripting.com is not up to date in its API reference so I looked through the cpp bindings that came with the release - pkg_moho.lua_pkg couldn't find any mention of it there either.. so in the end I left that bit commented out after testing it for the default limit of 10.
Wes, I will check your script to see how its done
https://we.tl/t-aRdFXfsDAu
Just pop both files in the Scripts->Tool directory, Ctrl-Shift-Alt-L to reload scripts in Moho, then new stopwatch icon will appear in tools pallet. Select your layers and click on stopwatch to toggle their visibility in timeline.
But I couldn't find the API reference to tell me the 'Maximun Selected Layers' setting. I assumed it would be in MohoGlobals but couldn't find it there. Then I thought since its a recent addition maybe mohoscripting.com is not up to date in its API reference so I looked through the cpp bindings that came with the release - pkg_moho.lua_pkg couldn't find any mention of it there either.. so in the end I left that bit commented out after testing it for the default limit of 10.
Wes, I will check your script to see how its done
- synthsin75
- Posts: 9981
- Joined: Mon Jan 14, 2008 11:20 pm
- Location: Oklahoma
- Contact:
Re: Layers Timeline
I printed out the Moho globals and API to double check, but doesn't look like we got direct access to the maximum selected layers that will display in the timeline.
So I just read the setting out of the preferences (user.setting) file in AppData, via moho:UserPrefsFile().
So I just read the setting out of the preferences (user.setting) file in AppData, via moho:UserPrefsFile().
- Wes
Donations: https://www.paypal.com/paypalme/synthsin75 (Thx, everyone.)
https://www.youtube.com/user/synthsin75
Scripting reference: https://mohoscripting.com/
Donations: https://www.paypal.com/paypalme/synthsin75 (Thx, everyone.)
https://www.youtube.com/user/synthsin75
Scripting reference: https://mohoscripting.com/
Re: Layers Timeline
Thanks Wes, very useful info - I didn't know about UserPrefsFile.
I've fixed my script to now show alert if you hit maximum visible layers on timeline limit.
https://we.tl/t-ieSvwjfmII
Also modified it to take in to account how many layers are already visible on the timeline when you call the script.
I noticed your script is checking for Moho version 13.55, I think the maximum selected layers setting was introduced before that, I'm running 13.53 and I have that setting.
Scripting is fun, thank you.
BTW Any advice of best practice regarding the script would be very welcome. (I noticed that you made a comment about not breaking out of io.lines loop in case the file is left open, I google that and found responses suggesting that the garbage collection closes the file even if the loop crashes ? https://stackoverflow.com/questions/342 ... s-happened. )
In case the we.transfer link expires, I'll include the script here:
With its icon:
Instructions: This is a Tool script so just pop both the script (GG_SeeOnTimeline.lua) and its icon (GG_SeeOnTimeline.png) in the Scripts->Tool directory, if Moho is already running then press Ctrl-Shift-Alt-L to reload scripts, then new stopwatch icon will appear in tools pallet. Select your layers and click on stopwatch to toggle their visibility in timeline.
I've fixed my script to now show alert if you hit maximum visible layers on timeline limit.
https://we.tl/t-ieSvwjfmII
Also modified it to take in to account how many layers are already visible on the timeline when you call the script.
I noticed your script is checking for Moho version 13.55, I think the maximum selected layers setting was introduced before that, I'm running 13.53 and I have that setting.
Scripting is fun, thank you.
BTW Any advice of best practice regarding the script would be very welcome. (I noticed that you made a comment about not breaking out of io.lines loop in case the file is left open, I google that and found responses suggesting that the garbage collection closes the file even if the loop crashes ? https://stackoverflow.com/questions/342 ... s-happened. )
In case the we.transfer link expires, I'll include the script here:
Code: Select all
-- **************************************************
-- Provide Moho with the name of this script object
-- **************************************************
ScriptName = "GG_SeeOnTimeline"
-- **************************************************
-- General information about this script
-- **************************************************
GG_SeeOnTimeline = {}
function GG_SeeOnTimeline:Name()
return 'Toggle Layers On Timeline'
end
function GG_SeeOnTimeline:Version()
return '1.0'
end
function GG_SeeOnTimeline:UILabel()
return 'Toggle Layers On Timeline'
end
function GG_SeeOnTimeline:Creator()
return 'GGoblin'
end
function GG_SeeOnTimeline:Description()
return 'Toggle Layers On Timeline'
end
-- **************************************************
-- Is Relevant / Is Enabled
-- **************************************************
function GG_SeeOnTimeline:IsRelevant(moho)
return true
end
function GG_SeeOnTimeline:IsEnabled(moho)
return true
end
-- **************************************************
-- The guts of this script
-- **************************************************
function GG_SeeOnTimeline:Run(moho)
moho.document:SetDirty()
moho.document:PrepUndo(nil)
--
-- find out how many layers are already visible on the timeline
--
local count = 0
local layers_on_timeline = 0
repeat
local layer = moho.document:LayerByAbsoluteID(count) -- iterating using LayerByAbsoluteID ensures layers inside groups are also iterated, CountLayers only iterates top-level layers
if layer then
count = count + 1
if layer:IsShownOnTimeline() then
layers_on_timeline = layers_on_timeline +1
end
end
until not layer
--
-- find out what is the maximum number of visible layers allowed on timeline
--
local maximum_layers_visible_in_timeline = 10 -- default value, will use this if no entry for MaxTimelineLayers found in UserPrefsFile (ie old versions of Moho)
for line in io.lines(moho:UserPrefsFile()) do
d = string.match(line, '\"MaxTimelineLayers\"\t\"%d+\"')
if (d ~= nil) then
maximum_layers_visible_in_timeline = tonumber(string.match(d,"%d+"))
break
end
end
--
-- keep toggling visible layers until hit maximum, then alert user
--
for l = 0, moho.document:CountSelectedLayers()-1 do
local layer = moho.document:GetSelectedLayer(l)
if not layer:IsShownOnTimeline() then
layers_on_timeline = layers_on_timeline +1
if layers_on_timeline > maximum_layers_visible_in_timeline then
LM.GUI.Alert(LM.GUI.ALERT_INFO, 'Reached maximum number of layers visible in timeline: '..maximum_layers_visible_in_timeline,
'To increase limit:',
'Edit->Settings->Timeline->Max Selected Layers',
'OK')
return
end
else
layers_on_timeline = layers_on_timeline -1
end
layer:SetShownOnTimeline(not layer:IsShownOnTimeline())
end
end
Instructions: This is a Tool script so just pop both the script (GG_SeeOnTimeline.lua) and its icon (GG_SeeOnTimeline.png) in the Scripts->Tool directory, if Moho is already running then press Ctrl-Shift-Alt-L to reload scripts, then new stopwatch icon will appear in tools pallet. Select your layers and click on stopwatch to toggle their visibility in timeline.
- synthsin75
- Posts: 9981
- Joined: Mon Jan 14, 2008 11:20 pm
- Location: Oklahoma
- Contact:
Re: Layers Timeline
Good catch on 13.5.3. I checked, and that is when max selected layers was introduced. Also, good idea about checking existing displayed layers.
I've added both to mine.
I lifted that io.lines code from another script of mine, where waiting for garbage collection wasn't closing the file fast enough. So I found less evaluation and allowing the loop to end naturally worked faster. In most cases, that shouldn't be critical.
Looking at your code, IsRevelant and IsEnabled aren't necessary if they're always true, as that's the default assumption. Doesn't hurt to have them though. I avoid using PrepUndo for display/UI/navigation stuff, so the user doesn't accidentally undo it while trying to undo creation/animation stuff. But that's just a personal preference of mine, not a best practices or anything.
I've added both to mine.
I lifted that io.lines code from another script of mine, where waiting for garbage collection wasn't closing the file fast enough. So I found less evaluation and allowing the loop to end naturally worked faster. In most cases, that shouldn't be critical.
Looking at your code, IsRevelant and IsEnabled aren't necessary if they're always true, as that's the default assumption. Doesn't hurt to have them though. I avoid using PrepUndo for display/UI/navigation stuff, so the user doesn't accidentally undo it while trying to undo creation/animation stuff. But that's just a personal preference of mine, not a best practices or anything.
- Wes
Donations: https://www.paypal.com/paypalme/synthsin75 (Thx, everyone.)
https://www.youtube.com/user/synthsin75
Scripting reference: https://mohoscripting.com/
Donations: https://www.paypal.com/paypalme/synthsin75 (Thx, everyone.)
https://www.youtube.com/user/synthsin75
Scripting reference: https://mohoscripting.com/
Re: Layers Timeline
Thank you for looking through the code and the advice, as a beginner is very valuable to me.
I haven't experimented with PredUndo yet, just saw it in skeleton scripts just before the script guts start, so I just kept it in.. I know its about setting undo points but not much more than that. Same with the other unused functions. But I agree its best to keep the script clean of unused junk.
Checking for existing displayed layers doesn't quite cover all the possibilities but I think its a good compromise before the script gets over engineered. If the user say chooses 3 layers to toggle, two of which are currently visible, and there are also 8 other unselected layers visible with max visible layers set to 10, then if the first selected layer being toggled is currently non visible, it wont get toggled as there are already 10 visible layers even though 2 of the selected layers are to be toggled to not visible so if those layers two were toggled first then the third could be toggled to visible to give a total of 9 visible layers - under the limit of 10.
I haven't experimented with PredUndo yet, just saw it in skeleton scripts just before the script guts start, so I just kept it in.. I know its about setting undo points but not much more than that. Same with the other unused functions. But I agree its best to keep the script clean of unused junk.
Checking for existing displayed layers doesn't quite cover all the possibilities but I think its a good compromise before the script gets over engineered. If the user say chooses 3 layers to toggle, two of which are currently visible, and there are also 8 other unselected layers visible with max visible layers set to 10, then if the first selected layer being toggled is currently non visible, it wont get toggled as there are already 10 visible layers even though 2 of the selected layers are to be toggled to not visible so if those layers two were toggled first then the third could be toggled to visible to give a total of 9 visible layers - under the limit of 10.
- synthsin75
- Posts: 9981
- Joined: Mon Jan 14, 2008 11:20 pm
- Location: Oklahoma
- Contact:
Re: Layers Timeline
True, it could be much more sophisticated. But for such a simple script, where most people probably aren't selecting a mix of shown and unshown layers, it should be sufficient.
But hashing out those possibilities is always good (sometimes fun) practice.
But hashing out those possibilities is always good (sometimes fun) practice.
- Wes
Donations: https://www.paypal.com/paypalme/synthsin75 (Thx, everyone.)
https://www.youtube.com/user/synthsin75
Scripting reference: https://mohoscripting.com/
Donations: https://www.paypal.com/paypalme/synthsin75 (Thx, everyone.)
https://www.youtube.com/user/synthsin75
Scripting reference: https://mohoscripting.com/