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

    String Cache Oddity Command Plugin

    Scheduled Pinned Locked Moved SDK Help
    2 Posts 0 Posters 215 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 06/01/2011 at 09:38, xxxxxxxx wrote:

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

      ---------
      Hi.
      Had this strange thing happening.
      I've used the string counting code for a while without issues but just
      recently the following has happened.
      I'm not sure if it's the R12.032 I've had since it came or the OSX
      update I just did ( to latest OSX 10.6.5)

      I set a string with a fixed amount of characters ("00000").
      Then for each frame I up the string ("00001", "00002" etc.).

      I use the code as Coffee Command Menu (cof/cob) and also
      in regular scripts (CSC) and it behaves different !

      I thought that a Command, once run, was detached from the document,
      no cacheing of the code in it etc.   but…. as a script (CSC) it works fine
      but as a cof/cob it only works correct the first time (after start of Cinema
      or reloading the cof in console.)
      Any subsequent runs, the string is not at it's default, "00000".
      Instead, depending on how many frames that have been run before,
      it could look like "00100".
      To solve it for now, I added a reset of the string last in the while loop.
      Just thought if I'm dreaming here….

      Cheers
      Lennart

      The code that could be used both as CSC and cof:

      doc->SetTime(doc->GetLoopMinTime()); // Set doc to PreView start time   
        
      while(doc->GetTime()->GetSecond() <= doc->GetLoopMaxTime()->GetSecond()) // while within preview range   
      {   
         var digits = "00000"; // how many digits, default string   
         var cframe = tostring(int(doc->GetTime()->GetFrame(doc->GetFps()))); // Current frame   
             digits = strins(digits,cframe,sizeof(digits)-sizeof(cframe));    // Build the resulting string   
               
             println(digits); // Check the resulting string   
        
             CallCommand(12414);               // Go To next frame   
             DrawViews(DRAWFLAGS_NO_THREAD);    // Viewport update   
             digits = strins(digits,"00000",0); //// !overwrite the cached(?) string. Needed for cof/cob command plugin. Strange?   
      }   
        
      doc->SetTime(doc->GetLoopMinTime()); // Set doc back to PreView start time
      
      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 14/01/2011 at 02:43, xxxxxxxx wrote:

        Sorry I can't confirm.

        This simple test plugin seems to work fine:

          
        ////////////////////  
        // MyMenuPlugin  
          
        class MyMenuPlugin : MenuPlugin  
        {  
          public:  
              MyMenuPlugin();  
              GetID();  
              GetName();  
              GetHelp();  
              Execute(doc);  
        }  
          
        MyMenuPlugin::MyMenuPlugin()   
        {  
          // Call the parent constructor  
          super();  
        }  
          
        MyMenuPlugin::GetID()   
        {  
          // TODO: Return a unique plugin id from http://www.plugincafe.com  
          return 1020660;  
        }  
          
        MyMenuPlugin::GetName()  
        {  
          // TODO: Return the text of the menu entry  
          return "test";  
        }  
          
        MyMenuPlugin::GetHelp()  
        {  
          // TODO: Return a help text that's displayed when the menu item is selected  
          return "test";  
        }  
          
        MyMenuPlugin::Execute(doc)  
        {  
          // Called when the menu item is chosen  
            
          // TODO: Do whatever you want  
          doc->SetTime(doc->GetLoopMinTime()); // Set doc to PreView start time  
          
          while(doc->GetTime()->GetSecond() <= doc->GetLoopMaxTime()->GetSecond()) // while within preview range  
          {  
              var digits = "00000"; // how many digits, default string  
              var cframe = tostring(int(doc->GetTime()->GetFrame(doc->GetFps()))); // Current frame  
              digits = strins(digits,cframe,sizeof(digits)-sizeof(cframe));    // Build the resulting string  
          
              println(digits); // Check the resulting string  
          
              CallCommand(12414);                // Go To next frame  
              DrawViews(DRAWFLAGS_NO_THREAD);    // Viewport update  
          }  
          
          doc->SetTime(doc->GetLoopMinTime()); // Set doc back to PreView start time  
        }  
          
          
        main()  
        {  
          Register(MyMenuPlugin);  
        }  
        

        cheers,
        Matthias

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