Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.
Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 21/08/2009 at 02:47, xxxxxxxx wrote:
User Information: Cinema 4D Version: 10.5 Platform: Mac ; Language(s) : C.O.F.F.E.E ;
--------- Hi, please excuse the extreme beginner question, but I am trying to make a pluggin that updates only when the animation is playing. I've tried this:-
main(doc,op) { var number,on_off,coffee_tag,store_t,sec,last_time;
doc->SetFps( 25 );
coffee_tag=op->GetFirstTag();
while(coffee_tag) {if(instanceof(coffee_tag, CoffeeExpressionTag)) break; coffee_tag=coffee_tag->GetNext(); } if(!coffee_tag) return;
if(!(coffee_tag#ID_USERDATA:2)) return;
// GET TIME var t = doc->GetTime(); var sec = t->GetSecond();
if (sec == last_time)return;
number=coffee_tag#ID_USERDATA:1;
println (number);
{ last_time == sec; }
}
but no joy, any pointers would be greatly appreciated. Many regards Conor
On 21/08/2009 at 02:57, xxxxxxxx wrote:
What kind of plugin? An Expression Tag? We need some more information. The code you show here looks more like code from a Coffee Tag or Coffee Node.
Generally, store values like last_time OUTSIDE the main function.
Greetings, Jack
On 21/08/2009 at 03:11, xxxxxxxx wrote:
Hi Jack it's a Coffee tag, eventually I hope to make a pluggin that saves the user data from my coffee tag to a text document for each frame of my animation, but as you can see it is baby steps at the moment. If I want to store last_time outside the main function, should this go at the end of the script?
On 21/08/2009 at 03:48, xxxxxxxx wrote:
With a COFFEE tag you would do something like this:
> \> var lasttime; \> \> main(doc,op) \> { \> if (!lasttime) lasttime = doc->GetTime(); //initialize lasttime \> \> var time = doc->GetTime(); //current document time \> \> if (time->IsEQ(lasttime)) \> println("equal"); //times are equal \> else \> println("not equal"); //times are not equal, animation is playing \> \> lasttime = doc->GetTime(); //write current time back to lasttime \> } \>
\> var lasttime; \> \> main(doc,op) \> { \> if (!lasttime) lasttime = doc->GetTime(); //initialize lasttime \> \> var time = doc->GetTime(); //current document time \> \> if (time->IsEQ(lasttime)) \> println("equal"); //times are equal \> else \> println("not equal"); //times are not equal, animation is playing \> \> lasttime = doc->GetTime(); //write current time back to lasttime \> } \>
lasttime is a global variable, outside of main(doc,op).
In a plugin you can store the time in a local class variable. Rule of thumb, avoid global variables.
cheers, Matthias
On 21/08/2009 at 03:52, xxxxxxxx wrote:
Matthias you legend, thank you very much. Conor