Press button, command line c4d?

On 18/01/2016 at 14:14, xxxxxxxx wrote:

Hello all,

I have a plugin that acts on a scene according to the arguments given in the command line, but I notice that trying to call c4d.CallButton(bakeTag, c4d.BAKETEXTURE_BAKE) causes it to hang and, well, think about it until I end the process.  Is there a way to simulate c4d.CallButton() with -nogui, or is that a -no go? :)


Edit: This might be a really dumb question, I realize ^^

2nd: Thought it might be a threading issue, so I went:
if c4d.threading.GeIsMainThread() : 
c4d.CallButton(bakeTag, c4d.BAKETEXTURE_BAKE)
in desperation, but :shrug:

On 19/01/2016 at 01:27, xxxxxxxx wrote:


can you share some more information? How exactly do you execute you code in a nogui environment? Do you react to some PluginMessage? Do you handle a document that you load yourself?

Best wishes,

On 19/01/2016 at 07:38, xxxxxxxx wrote:

Hey Sebastian,

Yeah, just as you say:

def PluginMessage(id, data) :
    if id == c4d.C4DPL_COMMANDLINEARGS:
        doc = c4d.documents.LoadDocument("C:/path/file.c4d", c4d.SCENEFILTER_OBJECTS, None)
        #c4d.documents.SetActiveDocument(doc) <-- Silly test from earlier
        frame = GetFrame(sys.argv) #These two
        bakeTag = FindTag(doc) #defined elsewhere
        if bakeTag == None:
            return False
        #Button settings here
        c4d.CallButton(bakeTag, c4d.BAKETEXTURE_BAKE)

Thanks for your time (again)

+ I guess I could add my command (windows) : "C:\pathToC4D\cinema 4d.exe" -frameNum 10 -nogui "c:\pathToFile\file.c4d"

On 19/01/2016 at 09:57, xxxxxxxx wrote:


CallButton() will just do that: it will "press" that button. It won't wait for any result. So after CallButton() your script ends. The document seems to exist only in the scope of this function so it is freed.

Baking the texture is handled in a background thread. So when you press the button, this process is started and this will take a while. But as said, you document will be deleted in the meantime. So it is no surprise that is will crash.

The baking system relies on a working message and event system which is not present in a non-gui environment. So it might be impossible to make this work properly. Is there a specific reason why this has to run in a non-gui Cinema?

Best wishes,

On 19/01/2016 at 10:10, xxxxxxxx wrote:

Ahh, gotchya, thanks for that.

We're trying to run this with deadline across our render farm, which, naturally, is just a bunch of blades with only the command-line version of c4d.  We have, ehh, many shots with many frames that need this baking, and potentially will have many more, so this is our current bottleneck by quite a bit (on one machine it takes 1-2 hours, thanks to the size of the image and length of the scenes).

I'll do a bit more experimenting before I give up, but either way thanks again!

On 19/01/2016 at 10:58, xxxxxxxx wrote:

Well, that didn't last long; I think you're right...  Maybe there's an elaborate way to calculate the texture with C so as to eliminate the need for the Bake Texture tag and hence CallButton(), buuut I think I'll throw in the towel, for now.  Someone, here at work, found a sort of workaround via Alembic and Fusion that's doing pretty well.

On 20/01/2016 at 01:52, xxxxxxxx wrote:


just to make this clear: it is possible to create a scripted solution if you can use a "normal" Cinema 4D installation. It is just not possible to do this with a non-gui version.

Best wishes,

On 20/01/2016 at 06:37, xxxxxxxx wrote:

We've had similar problems. It would be great if the Bake Texture functionality was exposed in python. Then we could make our own Cmd Bake Texture plugins.
That way we could check for certain conditions with a pre-job script in Deadline and submit a baking job first and make the actual job dependent on the first. When baking is finished, the initial job would start. I've been fiddling with several hacky solutions (including trying to learn c++ to code the plugin myself) but with no luck so far :)