How to wait for orchestrator to finish before making another cycle of the for loop in a script like this:
import omni.replicator.core as rep
SHAPES = ['torus', 'sphere', 'cube']
for shape in SHAPES:
with rep.new_layer():
camera = rep.create.camera(
position=(0,0,1000),
look_at=(0,0,0)
)
sphere_light = rep.create.light(
light_type="Sphere",
temperature=rep.distribution.normal(6500, 500),
intensity=rep.distribution.normal(35000, 5000),
position=rep.distribution.uniform((-300, -300, -300), (300, 300, 300)),
scale=rep.distribution.uniform(50, 100),
count=2
)
render_product = rep.create.render_product(camera, (1024, 1024))
if shape=='torus':
model = rep.create.torus(semantics=[('class', 'torus')] , position=(0, 0 , 0))
elif shape=='sphere':
model = rep.create.sphere(semantics=[('class', 'sphere')], position=(0, 0, 0))
elif shape== 'cube':
model = rep.create.cube(semantics=[('class', 'cube')], position=(0, 0 , 0) )
with rep.trigger.on_frame(num_frames=10):
with model:
rep.modify.pose(
rotation=rep.distribution.uniform((0,-90, 0), (0, 90, 0)),
)
# Initialize and attach writer
writer = rep.WriterRegistry.get("BasicWriter")
writer.initialize( output_dir="_output/"+shape, rgb=True)
writer.attach([render_product])
rep.orchestrator.run()
To run this script I use the headless method
.\omnicode.code.sh --no-windows --omni/replicator/script=/home/user/test.py
This renders only the cube because it is the last cycle and no new orchestrator.run() is called.