I have created a Position and Rotation based animation in the Curve editor and Timeline.
I am not able to proceed further on saving that animation as an Animation clip and playing it through the Action graph.
I can see a Push graph that is getting created but I don’t want that to play Automatically in Play mode.
Goal : Create animations using Timeline and Save them as Animation clips for later use.
You can try just baking out the animation. Time sample playback should be faster.
# convert OV curve to time sample
import omni.anim.curve as curve_api
from omni.timeline import get_timeline_interface
curve_iface = curve_api.acquire_interface()
timeline_interface = get_timeline_interface()
stage = omni.usd.get_context().get_stage()
prim = stage.GetPrimAtPath("/World/Cone")
time_codes_per_second = stage.GetTimeCodesPerSecond()
anim_curve_names = curve_api.get_curves(prim)
# go through all the animation curves on the prim
for curve_name in anim_curve_names:
if curve_name:
keys = curve_api.get_keys(prim, curve_name)
key_times = [curve_api.key_time_to_time_code(key.time) for key in keys]
curve_start_key = key_times[0]
curve_end_key = key_times[-1]
attr = prim.GetAttribute(curve_name.rsplit(":", 1)[0])
# bake out time samples on the translate X curve from first key to last
for frame in range(int(curve_start_key), int(curve_end_key+1)):
timeline_interface.set_current_time(frame/time_codes_per_second)
curve_tx = curve_iface.evaluate("/World/Cone.xformOp:translate:x", frame/stage.GetTimeCodesPerSecond())
print(curve_tx, frame)
attr.Set(Gf.Vec3d(curve_tx, 0, 0), Usd.TimeCode(frame))