ZBrushCentral

Any chance to add timeline key via script?

Hi, I’m trying to make a script to add timeline key for each subtools in certain time. I tried to record macro but get nothing, any clue will be very helpful, thanks

Yes, you can do that. You need:

[FONT=Courier New][TLNewKeyFrame, Optional time (if omited then use current time)]

Time is from 0 - 1.0 where 0 is the start time and 1.0 the end time of the whole TimeLine. So a value of 0.5 would be half way through.

You also need to make sure the correct track is selected before creating a key frame. For that you use [TLSetActiveTrackIndex, track index].

You can find the TimeLine commands here:
http://docs.pixologic.com/user-guide/customizing-zbrush/zscripting/command-reference/#timeline

thanks Marcus, I tested several times but its failed, I think the main problem is I dont know how to get the right track after create a layer, do you have any suggestions ?

Here’s an example for importing a MDD file. In this instance the right track is automatically selected on importing the file. (While the track is selected you could store the track using [TLGetActiveTrackIndex] so you could recall it later.)

The script also adds key frames to the Camera track. To select the Camera track I simulate a click on the document background. If I remember correctly, this was more reliable than using the TimeLine commands.


IButton
,Add_MDD,[COLOR=#f86b6b]“Add an MDD file to TimeLine”,
//make sure we’re in Edit mode and can import an OBJ
IPress,Tool:Polymesh3D]
If,IGet,Transform:Edit]!=1,//if Edit mode is off
IPress,Layer:Clear]
//draw the polymesh
IClick,1004,IGet,Document:Width].5,IGet,Document:Height].5,IGet,Document:Width].5,IGet,Document:Height].95]
ISet,Transform:Edit,1]//edit mode on
]
//import OBJ
FileNameSetNext,[COLOR=#f86b6b]“Body.obj”]
IPress,Tool:Import]
//show the TimeLine
IPress,Movie:TimeLine:Show]
//select camera track
IClick,1004,-4096,-4096]
//add key frames to camera track
TLNewKeyFrame,0]
TLNewKeyFrame,0.5]
//import MDD
FileNameSetNext,[COLOR=#f86b6b]“Boxing.mdd”]
IPress,Tool:Layers:Import MDD]
//layer track will be automatically selected
//add key frames
TLNewKeyFrame,0]
TLNewKeyFrame,0.5]
//select camera track again
IClick,1004,-4096,-4096]
//set to start of TimeLine
TLGotoTime,0]
]

HTH,

I still get the wrong result. (sigh…)
I uploaded my script and video here, it must be something wrong with my code but I can’t find it using my current knowledge…

Hmm, not sure why but for some reason the Layer track wasn’t getting selected for that subtool. I’ve revised the script to select the track each time. Seems to work OK now.

mdd_animation.txt (1.04 KB)mdd_animation.txt (1.04 KB)

thanks, it works perfect !