Uniqe instances

Hi, I have two folder paths: one for “dolls” and one for “hose”. I need to instantiate from the two groups such that each instance is uniqe.

right now I get duplicates of dolls and hoses:

import omni.replicator.core as rep

HOSE_ON_GROUND_ASSETS_DIR = "C:/Users/dsiss/Desktop/Synthia-LFS/Omniverse/randomization_assets/water_hose/rolled_on_ground"
DOLLS_ASSETS_DIR = "C:/Users/dsiss/Desktop/Synthia-LFS/Omniverse/randomization_assets/toys/dolls"

plane_path = "/World/Plane"


with rep.new_layer():

	traversable_plane = rep.get.prim_at_path(plane_path)
	
	hoses_usd = rep.utils.get_usd_files(HOSE_ON_GROUND_ASSETS_DIR)
	hoses_prims = rep.randomizer.instantiate(hoses_usd, size=5, use_cache = False)
	with rep.utils.sequential():
	    with hoses_prims:
	        rep.modify.semantics(semantics = [("class", "hose")])
	
	dolls_usd = rep.utils.get_usd_files(DOLLS_ASSETS_DIR)
	dolls_prims = rep.randomizer.instantiate(dolls_usd, size=5, use_cache = False)
	with rep.utils.sequential():
	    with dolls_prims:
	        rep.modify.semantics(semantics = [("class", "toy")])

the with_replacement parameter only works with paths and I’m not sure how to implement that.

Thank you

And that is exactly what rep.utils.get_usd_files returns, a list of paths. So with_replacements=False in instantiate should work fine.

It uses distribution.choice, so note “the size of the elements being sampled must be larger than the sampling size”

1 Like

ah I see, I was sure all rep functions return a replicator item. Thank you so much for the timley responce.

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