Download

sequencer python scripting limitations

I’m finding that it’s not possible to add an animation clip to a track in sequencer via python. Has anyone else tried this? I am able to create a level sequence, add a track for a character, add a skeletal mesh animation track, add a section to that track… But not add actual animation to it. Here’s my working code up to that point:

char = ue.EditorLevelLibrary.spawn_actor_from_object(charAsset, [0,0,0])
charTrack = sequence.add_possessable(char)
animTrack = charTrack.add_track(ue.MovieSceneSkeletalAnimationTrack)

Has anyone gotten beyond this with python?

You’ll need to add a section on the track and set its range/duration. The section points to the animation asset.

Something like:
animSection = animTrack.add_section()
animSection.set_range(make_range_seconds(0, length))

You’ll need to set the animation asset on the section as well. I can’t remember off the top of my head, but it’s probably something like:

animSection.set_editor_property(“Animation”, yourAnimimationAsset)

Take a look in here for examples: Engine\Plugins\MovieScene\SequencerScripting\Content\Python

These examples are fantastic! Thanks, I didn’t realize there were examples hidden in the engine folder. Will dig into this.

i have a problem , how can i use python sequencer

I’m finding that it’s not possible from Python to add sequencer tracks for camera properties (like focal length) or particle systems toggle tracks. Has anyone found a way to do either?

I have same problem,add sequencer tracks for particle systems toggle tracks,did you find a way to do this?

I was able to add a particle systems toggle track, but not add keys to it. Adding the track is much the same as adding other tracks.

Hi guys,

tried to use the API this week and couldn’t make it work. I tried some of the examples in “Engine\Plugins\MovieScene\SequencerScripting\Content\Python” and not sure they are working.

When I create a LevelSequence and list the attributes using the dir() function, I don’t see any of the functions listed in the API doc.

I looked at the LevelSequence.h file and looks like the functions are maybe missing decorators if I compare to EditorLevelLibrary.h where the functions have a UFUNCTION(BlueprintCallable, Category = “Editor Scripting | Level Utility”) decorator.

I tried to add the decorator to the LevelSequence::GetMovieScene() function and then to recompile the code and I was able to see it in the LevelSequence attributes.

Looks like we are still missing some stuff to play with LevelSequences using python.

Did you enable the SequencerScripting plugin?

There’s a youtube channel by Alex Quevillon with tutorials on how to do this. I basically copied his scripts and they seem to work. (if you’re pasting this, double check for typos and indents)

def addAnimTrackOnPossessable(animPath, possessable):
animAsset = unreal.AminSequence.cast(unreal.load_asset(animPath))
params = unreal.MovieSceneSkeletalAnimationParams()
params.set_editor_property(‘Animation’,animAsset)
animTrack = possessable.add_track(track_type = unreal.MovieSceneSkeletalAnimationTrack)
animSection = animTrack.add_section()
animSection.setEditorPropery(‘Params’, params)
animSection.setRange(0,animAssetLength(animPath)