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

    filling array

    Scheduled Pinned Locked Moved SDK Help
    3 Posts 0 Posters 273 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 08:03, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:   10.5 
      Platform:      Mac OSX  ; 
      Language(s) :   C.O.F.F.E.E  ;

      ---------
      Hi, I'm continuing to attempt to write my coffee tag that eventually will export the tags user data for each frame to a text file. The user data for the tag is" on/off, input and print". the input will be connected to whatever via xpresso, while "on" will collect the values per frame (with a frame index number)into an array that will be dumped out to a text file when the "print" is activated. With the code I have at the moment the array is only getting the current frame.

      <<
      var lasttime;

      main(doc,op)
      {

      doc->SetFps( 25 );

      var number,on_off,coffee_tag,save_doc;

      // create index for array
      var t = doc->GetTime();
      var sec = t->GetSecond();
      var frame =int( t->GetFrame(doc->GetFps()));

      var max_time = doc->GetMaxTime();
      var max_sec = max_time->GetSecond();
      var max_frame =int(max_time->GetFrame(doc->GetFps()));

      var arr = new(array,max_frame,max_frame);
      arr[frame] =frame,number;

      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;

      number=coffee_tag#ID_USERDATA:1;

      // userdata switch to print to file
      save_doc=coffee_tag#ID_USERDATA:5;

      var i = 0;
      if (save_doc)

      for (i = 0; i < max_frame; i = i + 1) {
      println(arr _);}

      if (!lasttime) lasttime = doc- >GetTime(); //initialize lasttime

      var time = doc->GetTime(); //current document time

      if (time->IsEQ(lasttime))

      return;

      else

      println (arr[frame,frame]);

      lasttime = doc->GetTime(); //write current time back to lasttime

      }

      >>

      Any help greatly appreciated!
      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 12:47, xxxxxxxx wrote:

        In order to advance frames, you must doc->SetTime().

        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 24/08/2009 at 03:32, xxxxxxxx wrote:

          Hi Robert
          Thanks very much, i've changed my code to try to use the SetTime in the loop activated by "print", but I don't think I'm getting the basetime right, as I want the loop to increment through each frame but i'm getting an incompatible float/object message.

          I've attached the code below

          var lasttime;

          main(doc,op)
          {

          doc->SetFps( 25 );

          var number,on_off,coffee_tag,save_doc;

          // create index for array
          var t = doc->GetTime();
          var sec = t->GetSecond();
          var frame =int( t->GetFrame(doc->GetFps()));

          var max_time = doc->GetMaxTime();
          var max_sec = max_time->GetSecond();
          var max_frame =(int(max_time->GetFrame(doc->GetFps())) + 1);

          var arr_frame = new(array,max_frame);
          var arr_number = new(array,max_frame);
          arr_frame[frame] = frame;

          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;

          number=coffee_tag#ID_USERDATA:1;
          if (number != 0)
          {
          arr_number[frame] = number;
          }

          // userdata switch to print to file
          save_doc=coffee_tag#ID_USERDATA:5;

          var i = 0;
          if (save_doc)

          for (i = 0; i < max_frame; i = i + 1) {

          doc->SetTime(((t->GetFrame(doc->GetFps())) + i));               // HERE IS THE PROBLEM !!!

          print (frame);
                              print (",");
                              print( arr_number[frame]);
                              println(" "); }

          if (i == max_frame)coffee_tag#ID_USERDATA:5 = 0;//reset print after dump

          if (!lasttime) lasttime = doc->GetTime(); //initialize lasttime

          var time = doc->GetTime(); //current document time

          if (time->IsEQ(lasttime))

          return;

          else
                    
                  print (arr_frame[frame]);
                              print (",");
                              print (arr_number[frame]);
                              println(" ");

          lasttime = doc->GetTime(); //write current time back to lasttime

          }

          Any help greatly appreciated!
          Conor

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