How to generate spheres in first trigger, and cube in second trigger

How to generate spheres in first trigger, and cube in second trigger?
How to use rep.modify.register API?
The Scenario I met was I want to delete the specific replicatorItem and generate a new one in different trigger, Thanks!!

  def randomize_spheres():
      spheres = rep.create.sphere(
          position= rep.distribution.uniform((0,0,0), (2, 2, 2)),
          scale=0.1,
          count=2)
      return spheres.node
  rep.randomizer.register(randomize_spheres)

  def randomize_cube():
      cube = rep.create.cube(
          position= rep.distribution.uniform((0,0,0), (2, 2, 2)),
          scale=0.1,
          count=2)
      return cube.node
  rep.randomizer.register(randomize_cube)


  with rep.trigger.on_time(num=2,interval=5): 
      with camera:
          rep.modify.pose(
              position = (2, 2, 50),
              scale = (1, 1, 1),
          )
      spheres = rep.randomizer.randomize_spheres()
      with spheres:
          rep.modify.pose(
              rotation = rep.distribution.uniform((0,0,0), (2, 2, 2)),
          )
      # rep.modify.register(
      #     randomize_cube,
      # override=True)

Hello @lily.chen,

Replicator doesn’t come with a node to destroy prims, but you can easily (and with more performance) accomplish your goal using visibility toggling:

import omni.replicator.core as rep
rep.settings.set_stage_meters_per_unit(1)

def randomize_spheres():
    spheres = rep.create.sphere(
        position= rep.distribution.uniform((0,0,0), (2, 2, 2)),
        scale=0.1,
        count=2)
    return spheres.node
rep.randomizer.register(randomize_spheres)

def randomize_cube():
    cube = rep.create.cube(
        position= rep.distribution.uniform((0,0,0), (2, 2, 2)),
        scale=0.1,
        count=2)
    return cube.node
rep.randomizer.register(randomize_cube)


with rep.trigger.on_time(max_execs=2, interval=5): 
    spheres = rep.randomizer.randomize_spheres()
    cubes = rep.randomizer.randomize_cube()
    
    # Toggle visibility
    with spheres:
        rep.modify.visibility(rep.distribution.sequence([True, False]))
    with cubes:
        rep.modify.visibility(rep.distribution.sequence([False, True]))import omni.replicator.core as rep