PDA

View Full Version : ALT-shifting keys



DustinBrown
06-19-2008, 05:59 PM
I've looked through the lscript docs and I see where you can apply channel object agents do to things like return the value of a key or change the post behavior for a key, but I don't see anything for copying keys.

What I'd ultimately like my script to do is copy all keys for all objects in my scene and paste them one frame forward in time, and also paste it one frame backward in time. So for every key you had, you now have three keys...you have tripled each key.

I do this often in the dope sheet by selecting all keys, holding Alt, then dragging my keys one frame to the right then two frames to the left. It gets tedious, and ending repetitious tedium is pretty much the whole point of scripting.

Can someone point me in the right direction for accessing this kind of control through lscript, please?

Thanks,
Dustin

adamredwoods
06-22-2008, 02:24 PM
If you would want this to happen on demand, then it would be a GENERIC script, executed whenever you select it through a self-made button or run using lscript.

To accomplish by CHANNEL OBJECT AGENTS:
you would need to write some helper functions. There are examples that come with Lightwave's lscript docs.


light = Light();
c = light.firstChannel();
while(c)
{

c = light.nextChannel();
}

This example takes an object (a light) and creates:
- an object (agent) for the light
- an channel object (agent) for the channel

Then it goes through the channels and ( where the dots are) can do some operation.

You never know how many channels there are, as other plugins can add more channels, so a loop like the above is the best way.

If you need a certain channel, say position, you need to parse through the channels to find it. This is where helper functions work.

Lightwave has some helper functions

keyExists(<time>)
is a function you can use as well to get an array of channel objects that have a key.

Once you have your channel object, and it's the right one you want, you can set it using the channel object's methods such as

setKeyValue(<key>,<value>)

You would implement your copy by reading and writing the channel values.

... is there an easier way?
If you were only after something like say, copying the position of an object, then you could:
- copy position of object
- go to certain keyframe
- set position value
- go to next keyframe
- set position value
etc...
you could do the same with rotation and scale in your loop.

This sounds like what you're after, and would be the best method. Fairly straight forward to create this type of script.