is there any way to close cinema 4d app from the python script? i foundrestart cinema 4d command only in python sdk but what's about quit / exit command? is it possible?
i need it to free RAM after exporting scene in standalone render via python script.
Hi again ;),
what do you mean by "python script" here, a Script manager script or c4dpy?
For the latter you can use os.execl, which will run whatever you are passing to it in a new interpreter. There are many threads on this topic on stack-overflow, but there is no sane way to ensure that the first interpreter actually closes while second one runs. An easier solution would be to just stack two scripts in your os-dependent script language (i.e. a batch file in Windows).
If you want to close the GUI-app, I am afraid there is no command for that because of the security implications (how to handle unsaved content?), you could wiggle your way around it by getting the handle of the Cinema window, but the problem on how to handle unsaved content would remain.
If it is only garbage collection you are after, you could also use Python's gc module to halt your script until the garbage collector thinks it is done. But Cinema is sort of a special case due to the way its API is constructed, which can cause stuff to linger for quite a while, even if when you think you have removed all references.
I was curious and just tried c4d.CallCommand(12104) - it does close the GUI app even from a Python script. (And asks for unsaved content too; I suppose it won't close if you cancel but I didn't check that.)
Hi @wob there is noting built-in for that in Cinema 4D. but you can use the regular python way to kill the current process
But I just let you know, that it may be useless by nature python should be pretty good at not creating any memory leak, and should free the data as soon as possible, moreover your approach ( I don't know the whole pipeline) but may also be a big issue for a user since this will clause Cinema 4D without asking for saving. People may lose their work. So I really encourage you to be very careful with the use of this.