How to use scatter2d no_coll_prims parameter with prim created from rep.create.from_usd

import omni.replicator.core as rep
with rep.new_layer():
    CAPRICE = ''
    DESK = ''

    dome_light = rep.create.light(intensity=300, light_type="dome")
    plane = rep.create.plane(rotation=(90, 0, 0), scale=(5, 1, 5))
    desk = rep.create.from_usd(usd=DESK, semantics=[('class', 'desk')])
    with desk:
        rep.modify.pose(rotation=(0, 0, 0))

    def randomize_caprices():
        caprices = rep.create.from_usd(CAPRICE, semantics=[('class', 'caprice')], count=5)
        desks = rep.get.prims(semantics=[('class', 'desk')])
        with caprices:
            rep.modify.pose(rotation=(0, 0, 0))
        return caprices.node

    with rep.trigger.on_frame(num_frames=20):

In this code I try to use scatter2d to “avoid” placing prims that would intersect the desk prim which is imported from nvidia assets. Unfortunately, when using “Start” or “Preview” option from replicator, I get an error message indicating that:

“[Error] [omni.graph.core.plugin] /Replicator/SDGPipeline/OgnScatter2D: OmniGraph Error: Scatter2D Error: Expected prim at /Replicator/Ref_Xform/Ref to be of type UsdGeom.Mesh or UsdGeom.GeomSubset but got type Xform”

I think that the problem is just that usd assets apart from cubes, spheres, etc. are not supported with non_coll_prims parameter, which is quite strange. Is there any kind of workaround to make this script work?


Apologies for your trouble. Seems like a bit of a bug we have when referencing nested assets.

Thankfully there is a workaround for you

Update your rep.get.prims to use the prim_types parameter:

desks = rep.get.prims(semantics=[('class', 'desk')], prim_types=['Mesh'])
# or
desks = rep.get.prims(path_match='Desk', prim_types=['Mesh'])

What is happening is get.prims is returning Xforms as well as meshes, and scatter expects a Mesh. By narrowing the scope of get.prims we can exclude the Xform prims from the get.

1 Like

Thank you for your reply. How does the path_match parameter work? Replicator Python API says, that it does “Python string matching”. But from what I saw, only ‘Desk’ works. I tried to paste the whole path or only some parts of path to the usd file instead of ‘Desk’ to see how it works, but the prims did intersect the desk. So if I want to use this function with my usd asset, what should I write in path_match parameter? I also want to add that the first line of code, doesn’t work (I don’t get an error, but the prims still may intersect the desk).

desks = rep.get.prims(semantics=[('class', 'desk')], prim_types=['Mesh'])

I also get this warning when I try to execute script with this line:

[Warning] [omni.replicator.core.ogn.python._impl.nodes.OgnGetPrims] No prims found with given inputs: 

path_match works like Python string matching x in y

prim_match="Desk" in this case would be `if “Desk” in “/Replicator/Ref_Xform/Ref/ContemporaryOfficeLoweredDeskFull_C”

Which would return True

path_pattern uses regular expressions in Python, so they are more flexible in matching, but can be slower.

prim_match is faster in most cases, though it is simpler in the prim path string it matches

desks = rep.get.prims(semantics=[('class', 'desk')], prim_types=['Mesh'])

I also get this warning when I try to execute script with this line:

[Warning] [omni.replicator.core.ogn.python._impl.nodes.OgnGetPrims] No prims found with given inputs: 

Apologies, it errors on my side too, I didn’t notice the error the first time.


When you add semantics=[(...)] when creating an object, the semantic label is added to the parent Xform and not the child mesh prims. So doing rep.get.prims(semantics=[('class', 'desk')], prim_types=['Mesh']) returns nothing, since there are no mesh prims with the semantic label.

We’re going to add some logic to scatter functionality such that it will look for child meshes when given an Xform

But for now, desks = rep.get.prims(path_match='Desk', prim_types=['Mesh']) should work since "Desk" is in the prim path of the meshes

1 Like

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