4.2.0
4.1.0
4.0.0
2023.1.1
2023.1.0-hotfix.1
Other (please specify):
I want to know how to get the imported usd file object through python and control its movement (translation or rotation). In addition, how to get the size (length, width and height) of USD through python?Thank you very much for your help.
I have finished the code of obtaining the target size by referring to the contents in the document, but I don’t know if this is the recommended method. Is there a better method?
usd_context = omni.usd.get_context()
stage = usd_context.get_stage()
pallet_prim = stage.DefinePrim(f"/World/Pallet", "Xform")
pallet_prim.GetReferences().AddReference(Pallet_Asset_Path)
min_point, max_point = usd_context.compute_path_world_bounding_box("/World/Pallet")
if min_point and max_point:
pallet_length = abs(max_point[0] - min_point[0])
pallet_width = abs(max_point[1] - min_point[1])
pallet_height = abs(max_point[2] - min_point[2])
print(f"Pallet dimensions: Length={pallet_length}, Width={pallet_width}, Height={pallet_height}")
else:
print("Failed to compute the bounds of the pallet.")