I’m new to Python scripting using the Unreal API. I’m trying to write a script that will let me modify sequencer animation keys. I can get the channels (x position, y rotation, etc) with this:
SelChannels = unreal.LevelSequenceEditorBlueprintLibrary.get_selected_channels()
But the hitch is that it returns a list of objects with the class SequencerChannelProxy. SequencerChannelProxy is useless as far as I can tell…its just a struct which contains the name of the channel and it’s section. What I was hoping is it’d return object’s of class MovieSceneScriptingFloatChannel, which has all the functions I need (add keys, modify keys, etc).
Has anyone written a script that will do something similar?
Alternatively, is there any place where I can download some Unreal python scripts that work with animation extensively? I may be able to find some answers there.
Not really, but I was eventually able to cobble together this function. It will adjust the keys of a selected channel by a supplied amount.
def AdjustSelectedChannelsKeys(AmountToAdjust):
SelProxyChannels = unreal.LevelSequenceEditorBlueprintLibrary.get_selected_channels()
for ProxyChannel in SelProxyChannels:
section = ProxyChannel.section ### heres the section the keys are in
ProxyChannel.channel_name ### the channel name (i.e. Rotation.X)
for channel in section.get_channels():
if (channel.channel_name) == ProxyChannel.channel_name:
Keys = channel.get_keys()
for Key in Keys:
KeyTime = Key.get_time().frame_number.value
OldValue = Key.get_value()
Key.set_value(OldValue+AmountToAdjust)
try:
channel.remove_key( channel.add_key(time=unreal.FrameNumber(99999), new_value=1) ) ### this bit of stupidity is there to force the new values to be evaluated. Otherwise nothing happens in viewport until the user manually makes a change.
except:
pass
What I’d like to do next is to find a way to write a function to be able to pass it a control name and affect its keys, rather than actually have the user manually select a channel.