How to run replicator.randomizer every N frames instead of every frame in Omniverse Replicator

Hey,

I have an example where I want to change the positions of the objects every single frame, but only use replicator.randomize.materials every N frames. How can I achieve this?
Simply checking for a randomly generated python variable value won’t work since the replicator graph is built once at runtime, so that value will always be the same during the same replicator session.
Intuitively it seems that I would have to wrap the rep.distribution.choice around the replicator.randomize.materials somehow, but I can’t figure out how to do that.

Thanks for the help.

Hi @lukas.mahieu. Have you take a look at this for customizing the graph: How to get current frame number in Replicator

Hi Mati,
I did find that documentation before and tried to follow it. In that specific example they’re simply creating a new attribute and use that attribute value to do some calculations, whereas I want to extend the trigger_on() functionality which seems harder to do.
In the end I found an easier solution though, which is to just create two ‘trigger on’ contexts below each other (not hierarchical) which seems to work. Like so:

with rep.trigger_on(num_frames=N, interval=1):
     do stuff every frame

with rep.trigger_on(num_frames=N_fraction, interval=interval): #ensure that N_fraction*interval = N
    do stuff every **interval**

I guess another solution is to wrap everything in a python class and rebuild the entire graph with a new material loaded every interval frames. That does leave me with the question though on how to modify materials inside replicator while keeping all materials within a group of prims constant, like you would with replicator.modify, however replicator.modify.material doesn’t exist (yet?). (but I’ll create a separate post for that)