Turn off collisions for invisible objects in replicator

Hi!
I’m trying to simulate different layouts of cases on a pallet and I’m using the replicator to toggle the visibility of cases. The cases I use have to have a collision for other parts of the simulation I’m doing, but I’d like to turn the collision off when the case is invisible. This is the code I’m currently working with:

  def case_visibility_randomizer(self):
      omni.log.info(f"Randomize case visibility")
      case_pattern = r"/World/Pallets/Pallet_0/Layer_\d+/Case_\d+/"

      cases = rep.get.prims(path_pattern=case_pattern, prim_types="Mesh")
      with cases:
          rep.modify.visibility(rep.distribution.sequence([True, False]))
          rep.modify.attribute("physics:collisionEnabled", rep.distribution.sequence([True, False]))
      return cases.node

If I try to change the attribute as shown in the code I get the following error:

2025-03-18 13:48:33 [47,272ms] [Error] [omni.graph.core.plugin] /Replicator/SDGPipeline/WritePrimAttribute_physics_collisionEnabled: [/Replicator/SDGPipeline] OmniGraph Error: WritePrimAttribute Error: cannot reshape array of size 1 into shape (60,newaxis)
                 (from compute() at line 236 in /home/developer/.local/share/ov/pkg/isaac-sim-4.2.0/extscache/omni.replicator.core-1.11.20+106.1.0.lx64.r.cp310/omni/replicator/core/ogn/python/_impl/nodes/OgnWritePrimAttribute.py)
[35.910s] [Level.ERROR] [None] [Node.cpp:1860] : /Replicator/SDGPipeline/WritePrimAttribute_physics_collisionEnabled: [/Replicator/SDGPipeline] OmniGraph Error: WritePrimAttribute Error: cannot reshape array of size 1 into shape (60,newaxis)
                 (from compute() at line 236 in /home/developer/.local/share/ov/pkg/isaac-sim-4.2.0/extscache/omni.replicator.core-1.11.20+106.1.0.lx64.r.cp310/omni/replicator/core/ogn/python/_impl/nodes/OgnWritePrimAttribute.py)

Is there any way to turn the collider off, ideally directly linked to the visibility parameter of each case?
Thank you in advance for any input!

Hi there,

there seems to be an issue with rep.modify.attribute that it searches for the attribute on the child prim. I submitted a bug report for this.

As a workaround you could either use the functionality by making sure you apply it to the prim which has the attribute or you could
use a more flexible approach with replicator separating randomization, simulation, and data capturing.

  • you can do this by using rep.orchestrator.step() whenever you want to capture a frame
  • if you want to use the replicator built in randomization, you can use rep.trigger.on_custom_event() to trigger randomization, to avoid triggering when calling the rep.orchestrator.step() function
  • this allows you to also have USD or Isaac Sim API randomizations in the same pipeline, here you can for example use a workaround for replicator collision issue.

Here are some examples of such workflows:

Thank you for your answer, I will take a look at it!