Running a python script via commandline.exe ?

On 28/12/2014 at 18:48, xxxxxxxx wrote:

User Information:
Cinema 4D Version:   16 
Platform:   Windows  ;   
Language(s) :       PYTHON  ;

---------
Hi everyone,

I need to render more than 300 animations scenes with 8 differents cameras angles (wich makes roughly a total of 2400 videos 😂). Then, those videos will be composed and compressed by other softwares (after effect, ffmpeg). Because of this workflow, I'm using AutoIt (windows) to make the all chain work.

But I'm struggling with Cinema 4D. 

My Strategy:
- Using the commandline.exe with parameters.
- Finding a way to run a python script before the render begins (so i can switch camera and move a few other 3d object position)

My Questions:
1. Is it possible to do this this way, and if yes, how ?
2. If this strategy is wrong, what would you suggest ?

Thx in advanced for your help. :hugging:

Best.
William.

On 29/12/2014 at 09:01, xxxxxxxx wrote:

Hello,

what exactly do you mean with "Using the commandline.exe with parameters." ?

You can pass command line arguments to your plugin catching the C4DPL_COMMANDLINEARGS message. The SDK shows you an example.

Based on that command line arguments you could run a script when the rendering starts. A way to determine this event would be to catch a MSG_MULTI_RENDERNOTIFICATION message in any object in the scene, maybe a SceneHookData plugin.

Then you could run your Python script using a node of the type ID_PYTHONSCRIPT:

  
BaseList2D* op = (BaseList2D* )AllocListNode(ID_PYTHONSCRIPT);   
if (op)  
{  
 BaseContainer* data = op->GetDataInstance();     
 if(data)  
 {  
     data->SetString(PYTHONSCRIPT_TEXT, *code);   
     op->Message(MSG_SCRIPT_EXECUTE, nullptr);    
 }  
 blDelete(op);  
}  

Why exactly do you want to run a Python script (because when you catch this event you could run any C++ code)?

For such specialized tasks like yours there is no "right" strategy, just strategies that will help you doing what you want to do.

For questions regarding the Python SDK please use the Python subforum. Thanks.

Best wishes,
Sebastian

On 04/02/2016 at 08:41, xxxxxxxx wrote:

Originally posted by xxxxxxxx

Hello,

what exactly do you mean with "Using the commandline.exe with parameters." ?

You can pass command line arguments to your plugin catching the C4DPL_COMMANDLINEARGSmessage. The SDK shows you an example.

Based on that command line arguments you could run a script when the rendering starts. A way to determine this event would be to catch a MSG_MULTI_RENDERNOTIFICATION message in any object in the scene, maybe a SceneHookData plugin.

Then you could run your Python script using a node of the type ID_PYTHONSCRIPT:

 
BaseList2D* op = (BaseList2D* )AllocListNode(ID_PYTHONSCRIPT);   
if (op)  
{  
    BaseContainer* data = op->GetDataInstance();     
    if(data)  
    {  
        data->SetString(PYTHONSCRIPT_TEXT, *code);   
        op->Message(MSG_SCRIPT_EXECUTE, nullptr);    
    }  
    blDelete(op);  
}  

Why exactly do you want to run a Python script (because when you catch this event you could run any C++ code)?

For such specialized tasks like yours there is no "right" strategy, just strategies that will help you doing what you want to do.

For questions regarding the Python SDK please use the Python subforum. Thanks.

Best wishes,
Sebastian

So basically the suggestion is to write c++ plugin, which is invoked on the startup before rendering, which as a result invokes python script? There is no way to set priority for python plugins?

I'm trying to write a plugin, which changes scene settings before rendering occurs. However, as far as I noticed, Commandline.exe renderer does not load active document, and I cannot get any render data from the scene, nor I can set it 😠

On 05/02/2016 at 00:25, xxxxxxxx wrote:

Hello and welcome,

you are pushing some quite old thread. Maybe open some new thread in the proper subforum where you can describe your specific topic in detail?

In a non-GUI environment like the command line version there is no active document. If you use the "render" command line argument Cinema will load and render the specified scene when it is handling this command line argument. So the scene is not loaded until the "render" argument is processed. If you want to edit the document before it is rendered you have to load and edit it before Cinema renders it.

See also this thread: "Command line args before render"

best wishes,
Sebastian

On 05/02/2016 at 03:54, xxxxxxxx wrote:

Originally posted by xxxxxxxx

Hello and welcome,

you are pushing some quite old thread. Maybe open some new thread in the proper subforum where you can describe your specific topic in detail?

In a non-GUI environment like the command line version there is no active document. If you use the "render" command line argument Cinema will load and render the specified scene when it is handling this command line argument. So the scene is not loaded until the "render" argument is processed. If you want to edit the document before it is rendered you have to load and edit it before Cinema renders it.

See also this thread: "Command line args before render"

best wishes,
Sebastian

Hello,
Yeah, sorry for pushing an old thread. Just thought one problem could be summarised in single place. I''m not trying to achieve anything too fancy. Just set the render region borders via command line and maybe extend this functionality a bit in the future.

Seen reference thread before. Will try to write C++ plugin for that if that's the best approach.
Thanks!