Python Team Render Switch (Delay Issue)
-
On 22/07/2018 at 18:13, xxxxxxxx wrote:
Hey Everyone,
I have a straightforward setup that I'm trying to get working. Basically, I'd like to be able to change an object parameter at render time but specifically when I Team Render. Right now it's functioning but some of the render buckets are wrong.
Some pictures of what's rendering and what's in the VP.
http://ben-caires.imgbb.com/import c4d
def main() :
global Render
if c4d.CheckIsRunning ( c4d.CHECKISRUNNING_EXTERNALRENDERING ) :
print("render in progress...")
Render = c4d.CheckIsRunning ( c4d.CHECKISRUNNING_EXTERNALRENDERING ) -
On 23/07/2018 at 05:50, xxxxxxxx wrote:
Hi Bencaires, first of all, welcome in PluginCafe.
May I ask you your context (script manager, tag, object)? It looks like you are from the script manager, but I'm not sure.
Regarding your question, the issue comes from the fact Team Render is another instance of C4D, so it's why some buckets are wrong because they are calculated on the other instance of C4D which didn't get modified by your script.To use a script from the script manager is definitely not the way to go to modify a document which is currently rendering.
And I'm afraid there is no proper way to do it in python. The correct way would have been to implement a SceneHook, which is not available in python, only in C++.
But if it's just a matter of parameters changes (please read Threading Informations), you can create a python tag which will do the parameter switch for you.Moreover, your way to detect is not sufficient and there is no proper way to detect if the scene is currently rendered in Team Render.
The thread ID is only reliable in c4d, but what you could do is check if the scene is currently open in Team Render Client, which should do the trick.So the following script in a python tag attached to a cube is working nicely.
import c4d def main() : obj = op.GetObject() if c4d.CheckIsRunning(c4d.CHECKISRUNNING_EXTERNALRENDERING) and c4d.GeGetVersionType() != c4d.VERSIONTYPE_NET_CLIENT or c4d.GeGetVersionType() == c4d.VERSIONTYPE_NET_CLIENT: obj[c4d.PRIM_CUBE_LEN] = c4d.Vector(400) else: obj[c4d.PRIM_CUBE_LEN] = c4d.Vector(100)
If you have any question, please let me know.
Maxime. -
On 23/07/2018 at 10:54, xxxxxxxx wrote:
Thanks, Maxime! That worked perfectly. I ended up plugging in the main part of the code into my python xpresso node and it works now with team rendering.
import c4d def main() : global Render if c4d.CheckIsRunning(c4d.CHECKISRUNNING_EXTERNALRENDERING) and c4d.GeGetVersionType() != c4d.VERSIONTYPE_NET_CLIENT or c4d.GeGetVersionType() == c4d.VERSIONTYPE_NET_CLIENT: print("render in progress...") Render = c4d.CheckIsRunning(c4d.CHECKISRUNNING_EXTERNALRENDERING) and c4d.GeGetVersionType() != c4d.VERSIONTYPE_NET_CLIENT or c4d.GeGetVersionType() == c4d.VERSIONTYPE_NET_CLIENT c4d.EventAdd() if __name__=='__main__': main() c4d.EventAdd()
-
On 23/07/2018 at 16:04, xxxxxxxx wrote:
Hey Maxime, one last thing. It turns out that the parameters that the code changes remains in that state until the team renderer is finished.... Is there a way to fix this because sometimes the renders are 6 minutes long and the reason for this switch is to speed up the VP. Thanks!
-
On 24/07/2018 at 01:29, xxxxxxxx wrote:
Hi Bencaires,
First of all please read Threading Informations, Xpresso python node is the same thing than a Python tag. So that means you also can't add Event from an Xpresso (and in your case, it's not needed)
Moreover, I'm pretty sure you do the switch based on the value of your global variable, which is global for all documents/scene. Moreover CheckIsRunning, only checks if the external render is currently running, without telling you this document is currently rendering.
When you render a document, this document is actually cloned into the memory in order to be sure no modification is done while rendering (it's why you can still work and modify the scene in the VP, without affecting the rendered picture).
So why not simply attach a python tag to the object you want to change the parameter, make the check if it's currently rendering, and then change the parameter only in this document.
So maybe it's better to use the following code, which will check only if the current document is currently renderingobj = op.GetObject() t = c4d.threading.GeGetCurrentThread() if c4d.threading.IdentifyThread(t) == c4d.THREADTYPE_RENDEREXTERNAL or c4d.GeGetVersionType() == c4d.VERSIONTYPE_NET_CLIENT: obj[c4d.PRIM_CUBE_LEN] = c4d.Vector(400) # Change your parameter directly here else: obj[c4d.PRIM_CUBE_LEN] = c4d.Vector(100)
If you have any question please let me know !
Cheers,
Maxime