When I integrate the following code into my script
def get_objs(dir_path, obj_type=".usdc"):
textures = []
dir_path = str(Path(dir_path))
dir_path = dir_path + "/"
for file in os.listdir(dir_path):
if file.endswith(obj_type):
textures.append(dir_path + file)
return textures
OBJ_DIR = Path("D:\Porosity\objPorosities")
porosities = get_objs(OBJ_DIR, ".usdc")
(...)
def rand_porosities():
porosity = rep.distribution.choice(porosities)
defect = rep.create.from_usd(porosity)
with defect:
rep.modify.semantics([("class", "porosity")])
rep.randomizer.scatter_2d(target_object, seed=int(datetime.now().timestamp()))
rep.modify.attribute("scale", rep.distribution.uniform((0.05, 0.05, 0.05), (0.3, 0.3, 0.3)))
return defect.node
rep.randomizer.register(rand_porosities)
I get the following error meassages:
2025-05-30 14:22:14 [Error] [omni.kit.app.plugin] [py stderr]: ArgumentError: Python argument types in
2025-05-30 14:22:14 [Error] [omni.kit.app.plugin] References.AddReference(References, ReplicatorItem)
2025-05-30 14:22:14 [Error] [omni.kit.app.plugin] did not match C++ signature:
2025-05-30 14:22:14 [Error] [omni.kit.app.plugin] AddReference(class pxrInternal_v0_22__pxrReserved__::UsdReferences {lvalue}, class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > assetPath, class pxrInternal_v0_22__pxrReserved__::SdfLayerOffset layerOffset=Sdf.LayerOffset(), enum pxrInternal_v0_22__pxrReserved__::UsdListPosition position=Usd.ListPositionBackOfPrependList)
2025-05-30 14:22:14 [Error] [omni.kit.app.plugin] AddReference(class pxrInternal_v0_22__pxrReserved__::UsdReferences {lvalue}, class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > assetPath, class pxrInternal_v0_22__pxrReserved__::SdfPath primPath, class pxrInternal_v0_22__pxrReserved__::SdfLayerOffset layerOffset=Sdf.LayerOffset(), enum pxrInternal_v0_22__pxrReserved__::UsdListPosition position=Usd.ListPositionBackOfPrependList)
2025-05-30 14:22:14 [Error] [omni.kit.app.plugin] AddReference(class pxrInternal_v0_22__pxrReserved__::UsdReferences {lvalue}, class pxrInternal_v0_22__pxrReserved__::SdfReference ref, enum pxrInternal_v0_22__pxrReserved__::UsdListPosition position=Usd.ListPositionBackOfPrependList)
I can’t understand why the rep.create.from_usd(porosity) is causing the error even though the path to the .usdc seems to be fine. What else am I doing wrong?
(Replicator Python API 1.10.10)