Download

Sequencer Scripting to Export Data

Hi, i am searching for ways to export sequencer data to text files.

For example, i create a sequence by keyframing some lights properties like color and intensity.
Next i would like to be able to read each light, parse the keyframes/values pairs and write them to a text file
Then i could use the data to control real lights or export the sequence to another application.

If exporting a track to FBX, the data is exported in the file :slight_smile:
If a track is copy/pasted in text editor, the data is also present with time indication in ticks

I started looking in the Python Api, MovieScene should definately be useful:
https://docs.unrealengine.com/en-US/…sequence%20key

Does someone have experience with that?

With the Level sequence Actor Selected, i am able to get it and the level sequence in python…
But how would i be able to get MovieScene/MovieSceneSequence to get all the tracks and infos i want?

I do not see any method to get MovieScene from there
https://docs.unrealengine.com/en-US/PythonAPI/class/LevelSequenceActor.html?highlight=levelsequenceactor

What would be another “entry point”?


import unreal

sel = unreal.EditorLevelLibrary.get_selected_level_actors()
lsa = sel[0]    #level sequence actor
print(lsa)
lseq = lsa.get_sequence()    #level sequence
print(lseq)

There’s some python scripting examples for sequencer data here in the engine. Take a look and see if that helps.

Engine\Plugins\MovieScene\SequencerScripting\Content\Python\sequencer_examples.py

I cannot find this python file, has it been moved?
Also looking for way to export a camera sequence to FBX

Thanks!

It hasn’t moved. You have the SequencerScripting plugin enabled?
You might have to install with the Engine Source option.

There is also an sequencer_fbx_examples.py file. Here’s a snippet for fbx export from that file (the formatting might be a little off):



import unreal

'''
Summary:
This is an example of how to export fbx with animation information with sequencer. In this example we load a map and corresponding level sequence,
grab all of the bindings from that sequence, set some export options, then export the fbx file.
To save less you need to only choose those bindings you want to export.
Open the Python interactive console and do similarly as below:
import sequencer_fbx_examples
sequencer_fbx_examples.export_fbx("/Game/Maps/FbxTest","/Game/FbxTest", "D:\\FBX_Test.fbx")

Params:
map_asset_path - String that points to the map that conatains the possessables contained in the Movie Scene sequence.
sequencer_asset_path - String that points to the Movie Scene sequence asset.
output_file - String that shows the full path of the created fbx file.
'''
def export_fbx(map_asset_path, sequencer_asset_path, output_file):
# Load the map, get the world
world = unreal.EditorLoadingAndSavingUtils.load_map(map_asset_path)
# Load the sequence asset
sequence = unreal.load_asset(sequencer_asset_path, unreal.LevelSequence)
# Set Options
export_options = unreal.FbxExportOption()
export_options.ascii = True
export_options.level_of_detail = False
# Get Bindings
bindings = sequence.get_bindings()
# Export
unreal.SequencerTools.export_fbx(world, sequence, bindings, export_options, output_file)

return