THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 17/04/2012 at 02:41, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 13
Platform: Mac OSX ;
Language(s) : C.O.F.F.E.E ;
---------
Hi there,
I have a problem with a script i've been working on. It is supposed to key object B if object A gets keyed using autmatic keyframing. therefore the script listens if at the current frame object A gets keyed and then uses a callcommand(12410) to keyframe object B.
this works fine if i put the script in the scriptmanager and execute it manualy. but if i put it in a coffeetag so that it should execute automatically, it only works if object A already has had a key on this frame.
hope that was understandable
so heres the code:
main(doc,op)
{
if (op == doc->GetActiveObject()){
var time = doc->GetTime();
var fps= doc->GetFps();
var currentFrame = time->GetFrame(fps);
var track = op->GetFirstCTrack();
var abordwhile;
while (track && abordwhile!=true)// iterate through all recorded tracks
{
if (track->GetName() == "Position . X" || track->GetName() == "Rotation . H") //only for position and rotation tracks
{
var curve = track->GetCurve(CCURVE_CURVE, FALSE); //Find the curve on a track
var keyTotal = curve->GetKeyCount();// count how many keys are on the track
var k;
for(k=0; k<(keyTotal); k++)// iterating through the keys to find which is on the current frame
{
var keytime = curve->GetKey(k)->GetTime()->GetFrame(fps);// get the frame K is on
if (keytime==currentFrame)// if the frame key k is on is the same frame the slider is on
{
k = keyTotal; // set k equal to the total number of keys on the track to stop the iteration through the keys
abordwhile = true; // stop iterating through the tracks
var Keythis1=doc->FindObject("Keythis"); //get the object, set it active and key it
if (Keythis1){
doc->SetActiveObject(Keythis1);
CallCommand(12410);
println("there should be a key now");
doc->SetActiveObject(op);
}
}
}
}
track = track->GetNext();// go on and do the same thing to the next track until no more tracks are found
}
}
}
Thanx,
Bonzo