View Full Version : Set Document max time with Coffee (or Python) node

07 July 2012, 09:49 AM
Hi everyone,

I want to change the document max time depending of my camera chosen. I thought i link the frame number to a simple coffe node. But I am a little rusty on coding coffee athe moment.

node input maxtime=3000 frames.

BaseDocument()#DOCUMENT_MAXTIME = maxtime;

this obviusly doenst work. Please Help. :sad:

kind regards mogh

07 July 2012, 12:09 PM
It can be done like this:

var doc = GetActiveDocument();
var time = new(BaseTime);
var fps = doc->GetFps();
time->SetFrame(MaxTime, fps);

07 July 2012, 12:56 PM
Thanks Darter, works perfect. :bounce:

kind regards mogh

07 July 2012, 07:40 PM
Oh no, no, no

I tried your script and ran into a problem deleted it after a few hours and now my szene jumps back to 3125 frames regardsless what i do I checked all nodes I have none COFFEE Node in my szene anymore but still the szene jumps to 3125frames Max :argh:

Saving under another name does not help-
restartting is not an option at the moment hence I am rendering.

I guess I found a bug ...
sleepnes nights willl come ...


07 July 2012, 10:00 PM
Certainly doesn't sound right. Can you post an example?

07 July 2012, 03:22 AM
I am off to a business trip, I think restarting C4D will solf it. but perhaps try for yourselve.

distributer linked to the coffe node over "MaxTime" Port node.

My order of failure:
-> test the szene if it works with different max times in your szene
-> deactivate the Coffee Node
-> unlink the node
-> delete the node
-> opening closing didn't help
-> opening and closing on another Computer did help.

after that the script was still active for one number (somhow in the memory) and kept jumping my Documents Maxtime Back to 3125 if I tried to set it over this frame number anything below was working.

I Checked all my Xpressos this was the only Coffee Node.

-> opening closing didn't help
-> opening and closing on another Computer did help.

I'll try to reproduze the setup / strip down the file in a few days if possible.

kind regards

07 July 2012, 11:58 PM
Situation normal here when the node is disabled, expressions are globally disabled or the node is deleted.

Perhaps it's something specific to your setup. A stripped-down example would be helpful if that's possible.

07 July 2012, 12:55 AM
Try this, add a Python Expression Tag on a Camera.
Make a Userdata on the Tag, integer type where you set the lastframe
for the document based on the Active(render) camera.


# Last Frame of Document set by Active Camera example. tcastudios.comę2012
# Py Expression Tag to be used on Camera Objects.
# Make one Userdata set to Integer type.

import c4d

def main():
cam = op.GetObject()
if not cam.CheckType(c4d.Ocamera):
return False
if doc.GetActiveBaseDraw().GetSceneCamera(doc) != cam:
return False

lastframe = op[c4d.ID_USERDATA,1] # Userdata Integer

fps = doc.GetFps()
if doc.GetMaxTime().GetFrame(fps) != lastframe:

CGTalk Moderation
07 July 2012, 12:55 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.