Hey @moghurt,
Thank you for reaching out to us.
I tried using the pyp plugin to execute Python scripts when starting the software to modify the project file, but when I use the '-render' parameter, the Python code in the pyp plugin is executed after the rendering is complete.
I can only speculate as to what exactly you have been doing here, as you do not provide any details or code. Please have a look at Support Procedures: Asking Questions for how to ask good technical questions.
The general workflow for what you want to do here (given that one really wants to follow the plugin route) would be to implement PluginMessage for your plugin, and then try to run your code from there at a fitting point of time in the startup sequence of Cinema 4D. And while I would not rule out that -render has an impact on the startup sequence of Cinema 4D, the general claim that your Python code only runs after the rendering seems a bit far fetched. Because for events such as C4DPL_INIT_SYS and C4DPL_INIT modules and plugins have not been loaded yet, i.e., rendering is literally impossible at these points.
The plugin approach also assumes that you can inject without problems alien command line arguments into a Cinema 4D app call, e.g., \CINEMA 4D.exe"-nogui -render "render.c4d" -script "myscript.py" with -script being the alien argument. I am not quite sure that this would work, I would have to try myself. What also is problematic, is that you are likely not able to get hold of the render document on this route. The active document will be the empty document, not the render document, i.e., you cannot get hold of the BaseDocument for render.c4d. And you cannot just open and modify the document yourself, as Cinema might have already a lock on that file or is even already loading it.
All this makes using c4dpy instead much more attractive as you won't have these problems there. It is also the intended solution for what you want to do here: Modify one or many documents without a GUI in a fire and forget manner. A while ago we had the topic Extending the Command Line with Python where I showed a workflow for how to treat c4dpy as a Script Manager environment.
ℹ The thread is four years old, written in Python 2 syntax (you will have to convert to Python 3 syntax), and I was then not yet a Maxon employee but a student. So, you might run into some issues. But the principle is definitively reproduceable and I also do not see anything in my old code which seems like a really bad idea.
Your workflow could then look like this for doing the pre and post rendering events (as a bat, ps1, sh, or command file and assuming that you do not want to overwrite files):
c4dpy script_manager_environment.py -script my_script.py -in my_doc.c4d -out my_doc_pre.c4d
CommandLine -my_doc_pre.c4d ...
c4dpy script_manager_environment.py -script my_script.py -in my_doc_pre.c4d -out my_doc_post.c4d
Cheers,
Ferdinand