Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware 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
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Command line args before render [SOLVED]

    SDK Help
    0
    3
    888
    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
      Helper
      last edited by

      On 14/01/2016 at 09:12, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:    
      Platform:      
      Language(s) :     C++  ;

      ---------
      Hi,

      Is there a way to get a command line argument before the rendering process (started with -render)?
      Let say I want to add a custom argument to disable all HyperNurbs before rendering:

      C4D -nogui -render "scene.c4d" -disable_hn 1

      I use PluginMessage() with id == C4DPL_COMMANDLINEARGS to retrieve arguments.
      I also have a SceneHookData listening for MSG_MULTI_DOCUMENTIMPORTED in the Message method.

      My SceneHookData is correctly called before the render (when the document is loaded) but PluginMessage with id == C4DPL_COMMANDLINEARGS is called after the render.
      Thus, I can't access to the command line arguments in the SceneHookData::Message.
      And, as the GetCommandLineArgs() is only available for Linux, it is mandatory to use C4DPL_COMMANDLINEARGS to retrieve arguments.

      Example:

      C4D -nogui -render "scene.c4d" -disable_hn 1
        
      Loading project: scene.c4d
      Debug: SceneHookData::Message: Document imported
      Rendering frame 0
      Progress: 0%
      Progress: 100%
      Rendering successful: 1 sec.
      Debug: GetCommandLineArgs: disable_hn = 1 <- Too late
      

      Do I have to override all the rendering arguments (render, frame, oimage, omultipass, oformat, oresolution, threads) to call a -custom_render which I will process after -disable_hn ?

      How do an argument like -take works to be identified before -render?

      Thanks for any help in advance!

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

        On 15/01/2016 at 02:10, xxxxxxxx wrote:

        Hello,

        your plugin receives the command line arguments after the render process because your plugin has a later priority than the module that performs the rendering. So to get the command line arguments before that module you could change the priority of your plugin by catching the C4DMSG_PRIORITY message in PluginMessage() :

          
        case(C4DMSG_PRIORITY) :  
        {  
         SetPluginPriority(data, C4DPL_INIT_PRIORITY_XTENSIONS + 1);   
         return true;  
         break;  
        }  
        

        This should make sure that your plugin receives the command line arguments before the render module.

        Best wishes,
        Sebastian

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

          On 18/01/2016 at 01:43, xxxxxxxx wrote:

          Hi Sebastian,

          Thank you very much for your help, it works great!

          I tried to change the priority in the RegisterSceneHookPlugin method but it only works for SceneHookData::Execute.
          I have also made a test with SetPluginPriority but I think I have forgotten to return true after while it seems to be mandatory.

          I can now add all custom arguments I want, nice!

          Cheers,

          Yann

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