I'm working on a python tool for running the bake texture tag on launch of a project. The problem we have here is we do a lot of large scale animated spherical renders that need to be baked down to flat UVs. Running the bake texture tag on a single workstation can take hours and we often have a lot of them to do plus iterating the process every time there are revisions. We have a render farm but currently no way to distribute the baking process to the farm.
What I'm trying to achieve is a script that will execute the bake texture tag when it's opened on a render node. For example, I'll set up a render to submit to our render farm through Deadline, but when the render node launches it will run the python script and bake the texture before it starts rendering.
I wrote the following script that basically does what I want locally:
obj = doc.GetFirstObject()
tag = obj.GetFirstTag()
doc.SetActiveTag(tag,c4d.SELECTION_NEW)
c4d.CallButton(tag(), c4d.BAKETEXTURE_BAKE)
It works as long as my object and bake texture tag are at the top of the hierarchy.
I tried to put this into a python tag but I got an error:
"RuntimeError: must be called from the main thread"
So I guess I can't use the CallButton command from within the python tag.
Any ideas how can get this to work?