New tool: TIME TOOL

Moho allows users to write new tools and plugins. Discuss scripting ideas and problems here.

Moderators: Víctor Paredes, Belgarath, slowtiger

lehtiniemi
Posts: 107
Joined: Mon Jan 14, 2013 3:18 pm

New tool: TIME TOOL

Post by lehtiniemi »

Here's a tool I always wished existed in ASPRO. With lots of support from hayasidist and synthsin75 I managed to put it together. I'm really really really excited about this!!!

TIME TOOL 1.2 BETA
Download: http://www.juhanalehtiniemi.com/tmp/JL_ ... ol_1.3.zip [UPDATED 18.6.2016]

WHAT IT DOES:
It enables you to insert and delete time at the cursor position by click-dragging your mouse, enabling you to edit the timing of your animation much faster. It can also crop the selected range so it's easy to extract pieces of mainline into actions.

HOW DOES IT WORK:
Activate the tool and select "Edit all frames" if you want to affect the whole document. If unchecked, only selected layers will be affected. Place your playhead to where you want to insert or delete frames. Click-drag to left or right in the viewport. Drag left to delete and right to insert, clicking also deletes one frame. You will see the amount of frames being deleted or inserted in the top bar while dragging. Release mouse to apply insert/delete.

To crop all time around range, activate Crop-mode from top bar. Select range and all frames and time will be deleted outside the selected range. Drag direction doesn't matter when crop mode is active. Please note that "Edit all layers" DOES affect crop mode.

VERSION HISTORY:
1.3
Camera is now processed only once, being a global track.
If you can replicate incorrect behaviour, please let me know the steps to do it and maybe I'll fix it one day!

1.2
Now works even if objects are selected. In 1.1 this messed up the script.

1.1
Added crop-functionality.
Clicking in the viewport now deletes a frame instead of doing nothing. Makes easier to trim loose frames.

EXAMPLE USAGE: Extract animation into actions from mainline in seconds
Besides adding more frames or deleting loose frames within the animation, this tool helps you extract actions from timeline really neatly. Try this:
-Open animation where you've animated lots of character animation on the timeline
-Create an empty action and open it
-In the action window without leaving action editing, select --Mainline-- and hit copy button to copy full mainline into current action
-Activate TIME TOOL, check both "Edit all layers" and "Crop mode"
-Locate the animation snippet you want to turn into action in the timeline
-Drag in the viewport with the tool from the first frame you want to include and release mouse in the last keyframe you want to include
-Now you have extracted a small animation action from the main timeline and deleted everything else. Just clean up the action by deleting unneeded position data.

I take no responsibility if you lose your work because of this script, use at own risk and save before use.
Last edited by lehtiniemi on Sat Jun 18, 2016 10:18 am, edited 14 times in total.
User avatar
hayasidist
Posts: 3492
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: New tool: TIME TOOL

Post by hayasidist »

you might find an "update widgets" useful:

Code: Select all

function JL_time_tool:UpdateWidgets(moho)
	self.editAllLayersCheckbox:SetValue(self.editAllLayers)
end
that sets the value to be displayed in the checkbox to self.editAllLayers (which is from loadPrefs rather than the default assignment)
User avatar
synthsin75
Posts: 9934
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: New tool: TIME TOOL

Post by synthsin75 »

lehtiniemi wrote:I'm using the undo incorrectly and I don't know why it works now. The script manipulates multiple layers. In this script I only call "PrepUndo(nil)" once which should basically set the following actions non-undoable. But on the contrary, this creates one undo step for all my changes and it seems to work. I have no idea why.
Looking at some of my old scripts, I've actually used PrepUndo(nil) too. I had forgotten that you could give nil as a parameter, which is the only reason I assumed PrepMultiUndo was necessary. I think you found the right way to do it.
lehtiniemi
Posts: 107
Joined: Mon Jan 14, 2013 3:18 pm

Re: New tool: TIME TOOL

Post by lehtiniemi »

hayasidist wrote:you might find an "update widgets" useful:

Code: Select all

function JL_time_tool:UpdateWidgets(moho)
	self.editAllLayersCheckbox:SetValue(self.editAllLayers)
end
that sets the value to be displayed in the checkbox to self.editAllLayers (which is from loadPrefs rather than the default assignment)
Thanks both! I updated the tool and added crop mode. This is really cool! Please see the example usage, it'll help you extract animation snippets from mainline within some seconds. Updated the description as well.

hayasidist, I added the updatewidgets but where should I now introduce the default value when the user is using the tool for the first time? Or does Anime Studio call "Reset" when there's no prefs? Also, doesn't DoLayout set the value to self.editAllLayers as well at init?
User avatar
synthsin75
Posts: 9934
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: New tool: TIME TOOL

Post by synthsin75 »

When loading prefs, the second argument/parameter is the default value.
User avatar
hayasidist
Posts: 3492
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: New tool: TIME TOOL

Post by hayasidist »

as Wes said, and if that's not there, it's what you set in the initial assignment.
lehtiniemi
Posts: 107
Joined: Mon Jan 14, 2013 3:18 pm

Re: New tool: TIME TOOL

Post by lehtiniemi »

Thank you!

Hmm, I noticed that this tool has really weird behaviour when elements are selected (so that the red keyframe lanes are visible).

When I have points or bones selected and the red keyframe lane shows up, does this dynamic lane show up in the code as well? Do I somehow have to bypass the selected line? If yes, how can I detect it? If you create two points, keyframe them at two separate occations, then select one of them and then use this tool to add or delete time between them while other point is selected, something weird happens with the keyframes. What could it be? My initial idea would be that the selection keyframe lane shows up when going through channels and I apply duplicate movement to the selected objects. If this is what happens, how can I detect this "dynamic channel" that's not a fixed channel?

EDIT: Got it!

Code: Select all


class MohoLayerChannel {
  MohoLayerChannel();
  ~MohoLayerChannel();
 
  int32    channelID;
  LM_String  name;
  int32    subChannelCount;
  bool    selectionBased;
};
I just have to check that selectionBased is false.
User avatar
synthsin75
Posts: 9934
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: New tool: TIME TOOL

Post by synthsin75 »

Skip channels that have 'selected' in their name string. See the lm_listchannels script to see how to get their names.
lehtiniemi
Posts: 107
Joined: Mon Jan 14, 2013 3:18 pm

Re: New tool: TIME TOOL

Post by lehtiniemi »

synthsin75 wrote:Skip channels that have 'selected' in their name string. See the lm_listchannels script to see how to get their names.
Thanks! I also found that MohoLayerChannel has a bool called "selectionBased". I just have to check that it's false.
User avatar
synthsin75
Posts: 9934
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: New tool: TIME TOOL

Post by synthsin75 »

lehtiniemi wrote:
synthsin75 wrote:Skip channels that have 'selected' in their name string. See the lm_listchannels script to see how to get their names.
Thanks! I also found that MohoLayerChannel has a bool called "selectionBased". I just have to check that it's false.
Good find, and better solution.
User avatar
rylleman
Posts: 750
Joined: Tue Feb 15, 2005 5:22 pm
Location: sweden
Contact:

Re: New tool: TIME TOOL

Post by rylleman »

Been using the script quite a bit now. Works well, thank you!
Camera keys gets messed up though. They move very far.
Just now I edited a ~70fr animation, adding 2-3 frames at a handful of positions. I had a few camera keys at the end. Now after the edits the camera keys are at around fr.5400... While the animation keys span to around fr.80.
User avatar
synthsin75
Posts: 9934
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: New tool: TIME TOOL

Post by synthsin75 »

rylleman wrote:Been using the script quite a bit now. Works well, thank you!
Camera keys gets messed up though. They move very far.
Just now I edited a ~70fr animation, adding 2-3 frames at a handful of positions. I had a few camera keys at the end. Now after the edits the camera keys are at around fr.5400... While the animation keys span to around fr.80.
The camera keys are probably being adjusted for each layer, even though they're global keys. Should be easy enough to only move those keys the first time they are found. If the author doesn't get around to it, I'll check it out.
lehtiniemi
Posts: 107
Joined: Mon Jan 14, 2013 3:18 pm

Re: New tool: TIME TOOL

Post by lehtiniemi »

rylleman wrote:Been using the script quite a bit now. Works well, thank you!
Camera keys gets messed up though. They move very far.
Just now I edited a ~70fr animation, adding 2-3 frames at a handful of positions. I had a few camera keys at the end. Now after the edits the camera keys are at around fr.5400... While the animation keys span to around fr.80.
Hi! Thanks! :)

I haven't worked on this script for a while, but I'll update the script to the server, I think I fixed the camera issue back then. Please re-download.
User avatar
rylleman
Posts: 750
Joined: Tue Feb 15, 2005 5:22 pm
Location: sweden
Contact:

Re: New tool: TIME TOOL

Post by rylleman »

Seems to work well now!
Thank you!
User avatar
rylleman
Posts: 750
Joined: Tue Feb 15, 2005 5:22 pm
Location: sweden
Contact:

Re: New tool: TIME TOOL

Post by rylleman »

Another bug report... :wink:
Timeline markers disappear using Time tool.
Post Reply