Command line args before render [SOLVED]

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

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


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.


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!

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


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() :

 SetPluginPriority(data, C4DPL_INIT_PRIORITY_XTENSIONS + 1);   
 return true;  

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

Best wishes,

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!