SOLVED How to run Python script at moment scene is opened?

I'm trying to write cinema 4d python script, that will auto-run render function when scene is opened. How to run Python script at moment scene is opened?



unfortunately the is no feature in Cinema that will let you execute a script when a document has been loaded.

  1. Technically you could abuse one of the scripting nodes to do what you want to do, but I would not recommend this, due them being bound to a threaded execution and other pitfalls.
  2. You could write yourself a plugin that does what you want. A MessageData plugin could be used for that for example.
  3. When you are not interested Cinema's GUI, you could also use c4dpy. Here I have recently shown, how you could use c4dpy to execute scripts on documents from the command line.



welcome to the forum and thanks for reaching us. 🙂

The workflow you are trying to achieve is a bit strange. Executing a script to launch a render when you open a scene is not something you always want to be active.

as @zipit said, if you want to launch render you can use c4dpy or our CommandLine

You could also create a script that ask for a folder and than open, launch the render and close the scene.
In our example you will find an example on how to launch a render

Using a MessageData will not really help since the message sent when you open a document need to be catched by the Message function and the MessageData only rely on CoreMessage.

Of course if you have any question feel free to ask. (we like to keep one thread per question)

I forgot in c++ you have the SceneHookData but it's not available in python.



i'll set that thread to solved tomorrow without further feedback