Choosing between multiple folder paths - replicator

Hi, I have a folder path path to fruits folder which has two folders in it; apples and oranges.
each folder holds a bunch of usds of that fruit.

Now, in my extension, I need to randomly select either oranges or apples and then scatter all the usds in the choosen path. this is my code:

def randomize_fruits(fruits_paths, traversable_plane):
   

    fruit = rep.utils.get_usd_files(rep.distribution.choice(fruits_paths))

    with rep.randomizer.instantiate(fruit, size=6, use_cache = False):
        rep.randomizer.scatter_2d(traversable_plane)

where fruits_paths is a list with two paths, one path to the apples directory and another to the oranges diretory.

This does not work. any help is much appriciated.

Hi there,

it could be that there are limitations with such branching in replicator graphs. A workaround is to separate the randomizers (apple and orange) and use Python for the randomized branching. You can do this using custom triggers and activating them at specific times. This can give greater flexibility for such scenarios:

Below is a simple example using custom triggers:

You could wrap your with something as:

if random.random() > 0.5:
    rep.utils.send_og_event(event_name="randomize_oranges")
else:
    rep.utils.send_og_event(event_name="randomize_apples")
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.