Scattering uniqe instances

i have a directory with 6 different usds. I use the following function to scatter 2 usd ata time on a plane in the stage:

def randomize_tool(directory, area, rotate = False, _size = 2):
        tools = rep.utils.get_usd_files(directory)
        traversable_plane = rep.get.prim_at_path(area)
        with rep.randomizer.instantiate(tools, size=_size, use_cache = False):
            rep.randomizer.scatter_2d(traversable_plane, check_for_collisions=True)
            if rotate:
                rep.modify.pose(rotation =rep.distribution.uniform((0,0,0), (0,0,180)))

now the issue is, that sometimes, twice of the same usd is instantiated. how do i limit the scatter function to select uniqe usds?

thank you

Hi there,

you can try using the with_replacement argument with False.

Here is its description:

When ``False``, avoids duplicates when sampling. Default ``True``. NOTE: if the paths is a ReplicatorItem, with_replacements will be ignored.

1 Like

awesome, thank you.

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