Increment value in xpresso


Hi. I have been reading as much as I can about incrementing values in xpresso and cannot find a working solution.

I found this thread but the images are gone, so I cannot see the solution.

Basically I want store and increment a value by 1, with a frame event. Then I can use the value to drive the coordinates of an object, pausing the incrementation with a switch when needed.

I can see that userdata is useful, but there is no obvious way to get the current value back out of it and into the Math.add node for the next increment.

Any ideas please?


Perhaps it would help to clarify the logic you are wanting to achieve:

Is it something like this?

If switch = 1 (on)
tally the change in timeline Frame number and store updated value in variable
pause the timeline incrementing

I’m a few years removed from XPresso and don’t recall if you can store variables. (?)


Yes – you’ve encapsulated it well. Store the number of frames passed through in a container, whilst a condition is true. Then be able to resume counting frames from where it last left off.


The best way around Xpresso hell is to think pragmatically i.e. use a null object’s keyframed position to drive the animation. I have always taken this approach with Xpresso to minimise the grief of using it. It might be easier to create a stepped movement of a Null than arse with Xpresso.

I think you might be after a ratchet style movement or stepper motor movement and I’m sure I’ve seen Xpresso tutorials somewhere in my time.

Someone with a bit of Python know how could help you out in the script node. This would be the easier route to just test for a boolean switch, increment count arrangement.

Nodes of interest to you will be the History node, Time node, Freeze node and various compare nodes.


Thank-you for you input and ideas.

I have used the Memory node, Freeze node, MonoFLop and other logic nodes in my experiments with this problem. The Memory node only seems to store values from objects that are moved in the timeline using standard tweening, so I have ahd to rule that one out.

Null object. Interesting idea, but I’m not sure how a keyframed Null object would help me store a value. I’m trying to do something that is not built on fixed keyframes.

I have been wondering whether Python would work. I think I used Python once before in xpresso. I need to find out whether a python script attached to an expresso node network can store values. I’m not clear on that, yet. But it sounds like another thing I can try.


Not having the advantage of knowing what you’re trying to achieve it’s very difficult to help further.
But good luck anyway.


The answer is to use a Python node with a global variable.

Like this

import c4d
#Welcome to the world of Python

def main():
    global Output1
    global store
    frame = doc.GetTime().GetFrame(doc.GetFps())
    if frame == 0:
        store = 0 # start value
    if Input2:
        store += 1
    Output1 = store

Here Input2 was set up as a Boolean, to switch the counter updates on and off
Someone on another board showed me how to set the global on frame 0


Glad you got a solution.

I’m sure I had an Xpresso random walk generator which would’ve stored position on each loop. I guess I may have used a few lines of COFFEE back then.


Thank-you. A walk-generator exactly what I’m making. :slight_smile:

And I’ve got it working now,.


Well if you had mentioned you were making a walk generator I definitely wouldn’t have suggested keyframes as a solution. :laughing:

I even tried to find an old skool tutorial from way back from someone like Robert Leger or Simon Holmedal but YT gets more and more difficult to find the older stuff from the golden era of Xpresso.

Is it possible to do a random walk effect with Scene Nodes?

I’m still trying to find someone who is using Scene Nodes, the C4D community appears to have largely shunned them.


Well if you want legacy xpresso check out this site


Random walk -


Start a Scene Nodes section.


It is only legacy xpresso site no new stuff


Yeah, on reflection creating a Scene Nodes section would be a complete waste of time as virtually no one is interested in it.

Just running through the Maxon NAB speakers subjects it’s just filled with the same old tired and cliched subject matter. Chris Schmidt demoing a rather uninspiring ‘Grid’ generator is as good as Scene Nodes gets on the Maxon stage.