This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# how to do references to multiple files | |
import omni.usd | |
from pxr import UsdGeom | |
stage = omni.usd.get_context().get_stage() | |
sphere = stage.OverridePrim('/my_prim') | |
sphere.GetReferences().AddReference('./HelloWorld0.usda') | |
sphere.GetReferences().AddReference('./HelloWorld1.usda') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# USD create camera and set attributes | |
import omni.usd | |
from pxr import UsdGeom, Gf, Usd, UsdGeom, Vt, Sdf | |
stage = omni.usd.get_context().get_stage() | |
camera = UsdGeom.Camera.Define(stage, f'/Motions/my_camera0') | |
camera.CreateClippingRangeAttr().Set((1,1000000)) # e.g. (1, 1000000) | |
# camera.AddTransformOp().Set(tx) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# USD get prim | |
import omni.usd | |
from pxr import UsdGeom | |
stage = omni.usd.get_context().get_stage() | |
prim = stage.GetPrimAtPath('/Motions') | |
# look at children of prim and print path as string | |
target_prim_path = prim.GetAllChildren()[0].GetPath().pathString |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# USD get transform property at path | |
import omni.usd | |
prim_path = '/Motions/traj_' | |
stage = omni.usd.get_context().get_stage() | |
prop = stage.GetPropertyAtPath(f"{prim_path}.xformOp:transform") | |
value = prop.Get() | |
print(value) | |
# or |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# procedural variants | |
import omni.usd as _usd | |
stage = _usd.get_context().get_stage() | |
rootPrim = stage.GetPrimAtPath('/base_stage') | |
#rootPrim = stage.GetPseudoRoot() | |
vset = rootPrim.GetVariantSets() | |
print(vset.GetNames()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# import omni.kit.app as _app | |
# import omni.usd as _usd | |
# import omni.client | |
# import omni.renderer_capture | |
# import omni.timeline | |
# from omni.kit import app | |
# USD setting viewport | |
width = 640 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Not sure what I have here | |
# from pxr import Gf, Usd, UsdGeom | |
# pose = Gf.Matrix4d(0.10028808960009783, 1.0899614544257474e-13, -0.9949584408830167, 0, -0.2896496895839791, 0.9566873438849783, -0.02919560539207469, 0, 0.9518641480843092, 0.29111737504021507, 0.09594434606284785, 0, 170.13235291094, 118.33856922920114, -26.433392816374774, 1) | |
# rotateAroundX = Gf.Matrix3d(1, 0, 0, 0, 0, -1, 0, 1, 0) | |
# rotation = pose.ExtractRotation() | |
# print(f'rotation={rotation}') | |
# print(f'type(rotation)={type(rotation)}') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pxr import UsdGeom, Usd, UsdGeom | |
stage = Usd.Stage.Open('stage.usda') | |
device_prim = stage.GetPrimAtPath('/world/device') | |
for prim in Usd.PrimRange(device_prim): | |
if prim.IsA(UsdGeom.Camera): | |
print(prim.GetName()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pxr import UsdGeom, Usd | |
stage_path = "D:\\Source\\internal\\projects\\example_simgen\\input\\stage_xxx2usd.usda" | |
stage = Usd.Stage.Open(stage_path) | |
prim_path = "/stage/Device_rig" | |
tx_prop = UsdGeom.Xform.Get(stage, prim_path) | |
times = tx_prop.GetTimeSamples() | |
transforms = [] | |
for time in times: | |
transforms.append(tx_prop.GetLocalTransformation(time=time)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xform = UsdGeom.Xform.Define(stage, '/my_prim') |
OlderNewer