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

    Going down the list of objects...

    Scheduled Pinned Locked Moved SDK Help
    3 Posts 0 Posters 268 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/10/2008 at 21:57, xxxxxxxx wrote:

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

      ---------
      Hello,
      As a beginner to COFFEE, I'm having trouble wrapping my head around the whole calling main() with each frame idea.

      With this example, I want to cause a set of objects to go from scale <A,A,A> to scale <B,B,B> every n frames, and one at a time.

      FRAME 0: OBJECT 1 CHANGES
      FRAME N: OBJECT 2 CHANGES
      FRAME N*2: OBJECT 3 CHANGES
      FRAME N*3: OBJECT 4 CHANGES

      As you can see, my code doesn't work.

      One big question is: what is the proper way to remember where in the list of objects I am from frame to frame (since, when main is called over and over, my pointer keeps getting sent back to the beginning)? The way I'm attempting to do this is to just start at the first object and renavigate my way down the list according to a count I'm keeping. But, besides being inelegant, it doesn't work.

      I'd be extremely appreciative if someone could point me in the right direction.

      The file
      is here , and the code follows below.

      Thanks!,
      Michael

      > var where = 0; \> var count = 0; \> main ( the_Document, the_Object ) \> \>      { \>      var cuber = the_Document->FindObject ( "First Cube" ); \> \>      //zap all cubes down to 0 scale at first frame \>      if (where == 0) \>           { \>                while (cuber) \>                     { \>                          cuber->SetScale ( vector (0.5, 0.5, 0.5 ) ); \>                          cuber = cuber->GetNext( ); \>                     } \>     \>      } \>       \>       \>      where++; \>      //reset to first cube \>      cuber = the_Document->FindObject ( "First Cube" );      \>      //every 30 frames \> if ((where % 30) == 0)      \>           { \>                count++; //counting how many times we've hit % 30, and thus, what cube we should be up to \>                println("where is ",where,""); \>                println("count is ",count,""); \>            \>                 \>                var i;      \>                //attemping to follow the list down to the current item by starting at the beginning and counting down \>                for (i = 0; i < count; i++); \>                     { \>                     println("i is ",i,""); //why is i always the same as count, and not counting up from 0 each time we hit % 30? \>                     cuber = cuber->GetNext( ); \>                }      \>            \>                if (cuber) \>                          { \>                               cuber->SetScale ( vector ( 1, 1, 1 ) );     //this only works once!      \>                          } \>           } \> \>      }

      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/10/2008 at 22:17, xxxxxxxx wrote:

        oops - looks like the scene file I posted doesn't have the above code in it. thisone does

        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 22/10/2008 at 09:16, xxxxxxxx wrote:

          fixed it:

          > var where = 0; \> var count = 0; \> var cuber; \> main ( the_Document, the_Object ) \> \>      { \> \>      //zap all cubes down to 0 scale at first frame \>      if (where == 0) \>           { \>                         cuber = the_Document->FindObject ( "First Cube" ); \>                      while (cuber) \>                 { \>                    cuber->SetScale ( vector (0.0, 0.0, 0.0 ) ); \>                    cuber = cuber->GetNext( ); \>                } \>                           \>                               //reset to first cube \>                         cuber = the_Document->FindObject ( "First Cube" );    \>                     } \>       \>       \>            where++;      \> \>           if ((where % 3) == 0)      \>           { \>              \>                      if (cuber) \>                 { \>                        cuber->SetScale ( vector ( 1, 1, 1 ) );        \>               } \>            \>                          cuber = cuber->GetNext( ); \>                          } \> \> }

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