Commands extension doesn't list when a Time is selected in the Timeline

Commands is great for learning how to do things in Create, so I can learn to automate them.

I am trying to animate this pool by setting the UV Texture Scale and / or Rotate values every 30 frames to give the water a little movement.

Everything I did show up in the Commands window, except for I don’t see the frame change from 0 to 30 in my first test.

Here is the output Python:

import omni.kit.commands

omni.kit.commands.execute(‘SelectPrimsCommand’,
old_selected_paths=,
new_selected_paths=[‘/Cube_04’],
expand_in_stage=True)

omni.kit.commands.execute(‘SelectPrims’,
old_selected_paths=[‘/Cube_04’],
new_selected_paths=[‘/World/Looks/Water_Opaque’],
expand_in_stage=True)

omni.kit.commands.execute(‘SetAnimCurveKey’,
paths=[‘/World/Looks/Water_Opaque/Shader.inputs:texture_scale|x’],
value=0.5)

omni.kit.commands.execute(‘Group’)

omni.kit.commands.execute(‘SetAnimCurveKey’,
paths=[‘/World/Looks/Water_Opaque/Shader.inputs:texture_scale|x’],
value=0.6000000238418579)

I guess my question is how do I change the time before SetAnimCurveKey is called? I want to set a key frame value at 0, Frame 30, Frame 60, etc., up to the end of the current scene length (I know how to do the loop, I don’t know how to change the the current frame programmatically.

Do you agree a Time value selected in the Timeline should set off some kind of an event in Commands to make the ‘Record Macro’ functionality complete? Executing the current generated Python would set the value to the current frame twice unless I am missing something.

Thanks

Thanks

Thanks

Hello there,
this may vary slightly depending on which version of Create you are using, but in general there are 2 ways you can do this:

  1. You can set the time explicitly in the command like this:
omni.kit.commands.execute('SetAnimCurveKey',
paths=['/World/Looks/Water_Opaque/Shader.inputs:texture_scale|x'],
time = Usd.TimeCode(30),
value=0.6000000238418579)
  1. you can set the time in the timeline (which is then used by SetAnimCurveKey if you don’t pass a time value)
def set_time_in_seconds(self, seconds: float):
     timeline_iface = omni.timeline.get_timeline_interface()
     timeline_iface.play()
     timeline_iface.set_auto_update(False)
     timeline_iface.set_current_time(seconds)


set_time_in_seconds(1.02)

Hope that helps
Eoin

Thank you for the code snippet.

Does Usd.TimeCode(30) set the time line to frame 30? The seconds is what I will use most likely, but I am just curious about the TimeCode.

I will experiment with this after work.

Thanks

If you mean the parameter in the first method, time= Usd.TimeCode(30), it will not set the timeline to frame 30. It is just for the key’s time only.

Do you mean that is like the duration of the keyframe?

Thanks

Hi @DataJuggler. Just wanted to jump in and answer your last question. Providing Usd.TimeCode(30) as a parameter does not specify a duration. It is saying, “Create a new keyframe at this frame number”. Also, it will not move the timeline to do that , you want to use the omni.timeline example the Eoin shared.

I’ll also be going over this question at our Developer Office Hours tomorrow at 11AM (PDT). You can join on Discord for a live follow-up or catch the recording on YouTube.

Thank you for the reply.

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

Here is the timestamped video link for the Developer Office Hour where I answered this question: NVIDIA Developer Office Hour - 07/22/2022 | NVIDIA On-Demand

And another bonus section: NVIDIA Developer Office Hour - 07/22/2022 | NVIDIA On-Demand

1 Like