If I understand what you are trying to randomize correctly, something like this should work:
import omni.replicator.core as rep
NUM_SPAWN = 4
with rep.new_layer():
l_plane = rep.create.plane(scale=10, position=(-500, 0, 0), visible=False)
r_plane = rep.create.plane(scale=10, position=(500, 0, 0), visible=False)
spheres_l = rep.create.sphere(count=NUM_SPAWN, semantics=[('class', 'sphere'), ('side', 'left')])
cubes_l = rep.create.cube(count=NUM_SPAWN, semantics=[('class', 'cube'), ('side', 'left')])
spheres_r = rep.create.sphere(count=NUM_SPAWN, semantics=[('class', 'sphere'), ('side', 'right')])
cubes_r = rep.create.cube(count=NUM_SPAWN, semantics=[('class', 'cube'), ('side', 'right')])
def randomize_shapes():
all_group = rep.create.group([spheres_l, cubes_l, spheres_r, cubes_r])
with all_group:
rep.modify.visibility(rep.distribution.choice([True, False]))
left_group = rep.create.group([spheres_l, cubes_l])
right_group = rep.create.group([spheres_r, cubes_r])
with left_group:
rep.randomizer.scatter_2d(surface_prims=l_plane)
with right_group:
rep.randomizer.scatter_2d(surface_prims=r_plane)
rep.randomizer.register(randomize_shapes)
camera = rep.create.camera(position=(1349.07818, 1648.22257, 2048.22328), look_at=(0, 0, 0), focal_length=38)
render_product = rep.create.render_product(camera, (1280, 720))
writer = rep.WriterRegistry.get("BasicWriter")
writer.initialize(output_dir="forum_test", rgb=True, bounding_box_2d_tight=True)
writer.attach([render_product])
with rep.trigger.on_frame(num_frames=50, rt_subframes=60):
rep.randomizer.randomize_shapes()
Basically, you’ll want to create all the shapes you want to randomize first in addition to the planes where you want them to be scattered. Then you can group them all and randomly toggle their visibility, and then scatter the “left” and “right” shapes on the appropriate plane.
Hopefully this helps!