Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Recent
    • Tags
    • Users
    • Login

    check if time has changed

    Scheduled Pinned Locked Moved SDK Help
    5 Posts 0 Posters 332 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      Helper
      last edited by

      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

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

        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

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

          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?

          1 Reply Last reply Reply Quote 0
          • H Offline
            Helper
            last edited by

            THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

            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 \> } \>

            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

            1 Reply Last reply Reply Quote 0
            • H Offline
              Helper
              last edited by

              THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

              On 21/08/2009 at 03:52, xxxxxxxx wrote:

              Matthias you legend, thank you very much.
              Conor

              1 Reply Last reply Reply Quote 0
              • First post
                Last post