Page 1 of 2

Lock Timeline Request

Posted: Mon Nov 17, 2008 8:50 am
by DK
Here is a script request from my daughter. She's frustrated at forgetting to return the timeline marker to frame 1 before she starts drawing. I managed to rescue her work it but she was ready to delete everything and start again. I must admit it really does me to.

How hard is it (or possible) to lock the timeline at frame 1 with a script?

Cheers
D.K

Posted: Mon Nov 17, 2008 9:48 am
by rylleman
Shouldn't be too hard. A script that check which frame you are at and if it's not frame 0 then send you to it.
Perhaps make it as an embedded script so you can attach it when you want it to be active and when you are done just unattach it.

Posted: Mon Nov 17, 2008 10:03 am
by DK
Hi Rylleman.

Sorry....I meant lock at frame "0" but I guess locking at any frame could be handy (not sure what for just yet). It would be great to implement it as a button in the Draw tool menu that you can click before you start drawing.

Cheers
D.K

Posted: Mon Nov 17, 2008 11:01 am
by heyvern
What happens if you unlock it and forget to lock it? Or would this be locked all the time to totally prevent drawing on any frame other than 0?

----------

We had a similar discussion on the Animation Master forum in regards to the "Big A" button. There is this "Big A" button at the top of the tool bar. If you click this button "off" then you don't add keys in the timeline. So if you translate or rotate an already animated object on frame 300 it moves the object based on the position at frame 0. You follow? You can globally move all the keys (AS needs that).

The problem arose because many people would forget to turn this button back on and spend a lot of time keying bone rotations for a pose or move an object and not realize they are not adding key frames or had moved a carefully positioned object all over the place.

Much discussion ensued regarding solutions. Make the button HUGE and have it VIBRATE annoyingly when it was off. Or have a huge warning pop up telling you that the "BIG A" button is UNCHECKED.

All of this tongue in cheek to some extent... because no matter how in your face or annoying a warning might be when your are in the zone everyone will at some point forget to check the "Big A" button.

I of course suggested a taser like wire connected to your chair that would be activated when keying with the "Big A" button unchecked.

;)

-vern

Posted: Mon Nov 17, 2008 1:10 pm
by DK
What happens if you unlock it and forget to lock it? Or would this be locked all the time to totally prevent drawing on any frame other than 0?
I don't see a problem with this at all? I see it as a menu button that you press prior to commencing drawing. After pressing it, the timeline would be locked until it was unlocked. It would probably serve as more of a reminder to you that you are in drawing mode on frame 0 when you realize that the timeline is locked and can't be moved. Then you could simply uncheck it if you wanted to to release it.

Oh well....maybe this IS a stupid suggestion but all I know is, I still keep creating keyframes on the timeline where they should not be and so does my daughter so it must have some merit.

Cheers
D.K

Posted: Mon Nov 17, 2008 1:36 pm
by mkelley
I know you know this D.K. but perhaps your daughter doesn't (and you haven't shown her) -- the "Highlight Frame 0" preference you can set.

Yep, it's not foolproof by any means, but at the very least you should turn this on. Visually I find it to work about 95% of the time -- that is, when I'm NOT on frame 0 I sense something is "wrong" at least and I've caught myself this way more than when it was turned off.

Perhaps it could be improved by Mike (maybe a bigger border or something) but I find it truly useful. That, along with the ability to copy back to 0 frame your "mistakes" (in the Animation menu) is all I think most folks really need.

(Speaking of which -- your daughter *does* know about this one, right? Because no one should ever start over just because they've done a lot of work in a different frame, when they are only a couple of mouse clicks away from being able to copy it back to frame 0).

Posted: Mon Nov 17, 2008 8:17 pm
by synthsin75
All of the 'creation' tools could be modified to only work on frame zero. Unless you're doing frame-by-frame, I assume that'd work. Even with a menu or button script, it'd have to work with the tools. :wink:

Posted: Mon Nov 17, 2008 9:01 pm
by jahnocli
synthsin75 wrote:All of the 'creation' tools could be modified to only work on frame zero.
That's a great idea. I'd vote for that -- simple, and it makes sense.

Posted: Mon Nov 17, 2008 9:08 pm
by heyvern
The simplest solution is the "IsEnabled" function near the top of every tool.

For example in the lm_add_point.lua tool modify the IsEnabled() function by adding an "if" statement to check the frame number.

Code: Select all

function LM_AddPoint:IsEnabled(moho)
	local mesh = moho:Mesh()
	if (mesh == nil) then
		return false
	end
	if (moho.layer:CurrentAction() ~= "") then
		return false -- creating new objects in the middle of an action can lead to unexpected results
	end
-----------------------------------------------------
-- New if statement to check for frame number
-----------------------------------------------------
	if (moho.frame <1) then
		return false
	end
-----------------------------------------------------
-----------------------------------------------------
	return true
end
This will cause the tool to be "grayed out" on any frame other than 0. You can insert this code into any of the tools. All tools have an IsEnabled function (pretty sure).

I can't think of any other way to do this "globally" to all the tools. I thought maybe an edit to the utilities script... but... even then you would still have to edit all the tools to call a different function.

If you want some kind of toggle or check box to turn this on and off add it to one of the tools or a custom tool and then check the value of that check box. This would require creating a check box value in some tool. You can get the value of that check box (but not change it) from any other tool. It could just be a simple tool with no other functions, just a check box to lock editing. Select the tool and check the box on or off.

in the code below myCustomToolCheckBox.lockEdit would be the value of the check box in the custom tool. I haven't explained here how to do that of course. :oops:

Code: Select all

function LM_AddPoint:IsEnabled(moho)
	local mesh = moho:Mesh()
	if (mesh == nil) then
		return false
	end
	if (moho.layer:CurrentAction() ~= "") then
		return false -- creating new objects in the middle of an action can lead to unexpected results
	end
-----------------------------------------------------
-- New if statement to check for frame number
-----------------------------------------------------
	if (moho.frame <1 and myCustomToolCheckBox.lockEdit == true) then
		return false
	end
-----------------------------------------------------
-----------------------------------------------------
	return true
end
-vern

Posted: Mon Nov 17, 2008 11:13 pm
by DK
Wow,....thanks Vern!!!! I slightly modified your script to do exactly what I wanted. I just adjusted the Greater than "0" value to Less than "0".
Thank you so much. Also this is an extremely interesting glimpse at how lua works.

jahnolci....Verns script really works. The add point tool is only active while on frame 0. I'm going to adjust the others right now!!!


-----------------------------------------------------
-- New if statement to check for frame number
-----------------------------------------------------
if (moho.frame >1) then
return false
end
-----------------------------------------------------
-----------------------------------------------------
Thanks for the red at frame 0 sugestion too mkelley. Unfortunately i still manage to stuff it up even when using that.
Also, thanks ryllman and synthsin75 for responding!

QUESTION to Vern....If I adjusted all the tools could I upload them to the forum as a lua bundle for other to unzip and drop into their own script tools lua folder?


Cheers
D.K

Posted: Mon Nov 17, 2008 11:20 pm
by synthsin75
A fuller solution would be to have each creation tool check frame zero for a keyframe on that 'selected' channel. I'm not real sure this can be done, but if it could, it could write a duplicate keyframe on frame zero if one doesn't exist.

So basically all keyframed channels are forced to have a key on frame zero. Maybe just a duplicate of the first keyframe on frames > 0 for frame 0?

This would also solve the problem of 'orphaned' keyframes. You know, those you can't delete unless you copy them to frame zero first.

Posted: Mon Nov 17, 2008 11:47 pm
by DK
Hi synthsin75.

The script seems to work great as it is! I'm using it now and can't seem to find any drawbacks at all. I only adjusted the add points, freehand draw, create oval,create arrow and create box tools and can now only draw at frame "0".

Cheers
D.K

Posted: Mon Nov 17, 2008 11:51 pm
by synthsin75

Code: Select all

----------------------------------------------------- 
-- New if statement to check for frame number 
----------------------------------------------------- 
if (moho.frame >1) then 
return false 
end 
----------------------------------------------------- 
----------------------------------------------------- 
This would actually leave the tool enabled on frames 0 & 1. Maybe that's what you want. If not, you want to make it:

Code: Select all

if (moho.frame > 0) then
return false
end
:wink:

Posted: Mon Nov 17, 2008 11:54 pm
by DK
Ahhh....thanks for tat synthsin5...I see.....i'll adjust it now.

Ok...brilliant synthsin and vern!!! I can't see a problem with uploading them so here they are if anyone's interested. (AS Pro) Just unzip and drop into your scripts/tool folder.

http://www.wienertoonz.com/drawframe0.zip


Cheers
D.K

Posted: Tue Nov 18, 2008 12:00 am
by synthsin75
Sorry about that, DK. Between the code you quoted and this:
I just adjusted the Greater than "0" value to Less than "0"
I was a little confused.

I assume you did it like this?:

Code: Select all

if (moho.frame > 0) then 
return false 
end
If not, I'm even more confused. :? :P :wink: