# Knowledge Base: UE4 Sequencer Python Cookbook

**URL:** <https://forums.unrealengine.com/t/knowledge-base-ue4-sequencer-python-cookbook/265097>\
**Category:** Editor Scripting\
**Tags:** unreal-engine\
**Created:** [December 9, 2021, 2:50am UTC](https://forums.unrealengine.com/t/knowledge-base-ue4-sequencer-python-cookbook/265097 "2021-12-09T02:50:32Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![RudyTriplett](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/rudytriplett/32/1197584_2.png) [@RudyTriplett](https://forums.unrealengine.com/u/RudyTriplett)\
**Post date:** [December 9, 2021, 2:50am UTC](https://forums.unrealengine.com/t/knowledge-base-ue4-sequencer-python-cookbook/265097/1 "2021-12-09T02:50:32Z")

</div>

Article written by Euan C.

UE4 Sequencer Python Cookbook

Fundamentals  
Sequencer is a cinematic editing tool that uses various specialized tracks which are used to define the makeup of scenes.  
This document will be fo…  
  
[https://dev.epicgames.com/community/learning/knowledge-base/0qK6/unreal-engine-ue4-sequencer-python-cookbook](https://dev.epicgames.com/community/learning/knowledge-base/0qK6/unreal-engine-ue4-sequencer-python-cookbook)

---

<div class="post-metadata">

**Author:** ![scottunreal](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@scottunreal](https://forums.unrealengine.com/u/scottunreal)\
**Post date:** [December 30, 2021, 5:58pm UTC](https://forums.unrealengine.com/t/knowledge-base-ue4-sequencer-python-cookbook/265097/2 "2021-12-30T17:58:46Z")

</div>

Hopefully, all of this will make it somewhere in the documentation. More examples and coverage of making/using unreal tools in your documentation and/or learning center would be very useful.

---

<div class="post-metadata">

**Author:** ![geordiem](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@geordiem](https://forums.unrealengine.com/u/geordiem)\
**Post date:** [September 7, 2022, 5:09pm UTC](https://forums.unrealengine.com/t/knowledge-base-ue4-sequencer-python-cookbook/265097/3 "2022-09-07T17:09:06Z")

</div>

with Python, how does one add a Geometry Cache (alembic) section pointing to the proper alembic cache?  
 ![adding_geom_cache](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/c/c/0cc462dff7268e2c043797a4bc56c3a78391b306.gif)

---

<div class="post-metadata">

**Author:** ![geordiem](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@geordiem](https://forums.unrealengine.com/u/geordiem)\
**Post date:** [September 10, 2022, 8:00pm UTC](https://forums.unrealengine.com/t/knowledge-base-ue4-sequencer-python-cookbook/265097/4 "2022-09-10T20:00:03Z")

</div>

Found some answers.  
Here is how to add a geom cache to a sequence:

```python

cache_asset = unreal.load_asset("/Game/path/to/cache_asset")
cache_actor = unreal.EditorLevelLibrary.spawn_actor_from_object(cache_asset,unreal.Vector(x=0.0, y=0.0, z=0.0))

actor_binding = level_sequence.add_spawnable_from_instance(cache_actor)
# adding a geom cache
cache_track = actor_binding.add_track(unreal.MovieSceneGeometryCacheTrack)
anim_section = cache_track.add_section()
anim_section.set_range(start_frame,end_frame) # start and end frames

# add the cache asset 
params = anim_section.get_editor_property("params")
params.set_editor_property("geometry_cache_asset",cache_asset)
unreal.LevelSequenceEditorBlueprintLibrary.refresh_current_level_sequence()

```

And this is of use to others who may be looking for it.  
Adding sub sequences to another sequence:

```python
 # this adds an empty subscenes track to add something too
master_track = top_sequence.add_master_track(unreal.MovieSceneSubTrack)
subseq = unreal.load_asset("/Game/path/to/subsequence" )
subsequence_section = master_track.add_section()
subsequence_section.set_sequence(subseq)
# shift to proper location in timeline
subsequence_section.set_range(start_frame,end_frame)

```

---

<div class="post-metadata">

**Author:** ![SkyOHorizon](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SkyOHorizon](https://forums.unrealengine.com/u/SkyOHorizon)\
**Post date:** [October 25, 2022, 5:00am UTC](https://forums.unrealengine.com/t/knowledge-base-ue4-sequencer-python-cookbook/265097/5 "2022-10-25T05:00:33Z")

</div>

Excuse me, How to create a morph target sequence using python? I have imported a fbx with morph targets of face, and I could using ui to set a level sequence, how to implement it with python? Thank you  
 ![屏幕截图 2022-10-25 125746](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/3/2/532e196665a584258cfc01880a0a67a799c224d4.png)

---

<div class="post-metadata">

**Author:** ![SkyOHorizon](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SkyOHorizon](https://forums.unrealengine.com/u/SkyOHorizon)\
**Post date:** [October 25, 2022, 5:11am UTC](https://forums.unrealengine.com/t/knowledge-base-ue4-sequencer-python-cookbook/265097/6 "2022-10-25T05:11:25Z")

</div>

Also，I have got another problem, when I first open the project(without opening the sequence), and using section.get\_channels() to get the Face’s channels, it will return None, but if I once open the level sequence, it could work, I have tested the metahuman’s control rig sequence, the issue didn’t occur. So does anything else I need to set with morph target or the sequence? Maybe it’s a bug(I have meet it both in 4.26.2 and 5.0.3)

---

<div class="post-metadata">

**Author:** ![nksoo7371](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@nksoo7371](https://forums.unrealengine.com/u/nksoo7371)\
**Post date:** [November 29, 2022, 5:54pm UTC](https://forums.unrealengine.com/t/knowledge-base-ue4-sequencer-python-cookbook/265097/7 "2022-11-29T17:54:30Z")

</div>

Did you find a solution?

---

<div class="post-metadata">

**Author:** ![q92ie83ir8](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/q92ie83ir8/32/88713_2.png) [@q92ie83ir8](https://forums.unrealengine.com/u/q92ie83ir8)\
**Post date:** [January 18, 2023, 10:05am UTC](https://forums.unrealengine.com/t/knowledge-base-ue4-sequencer-python-cookbook/265097/8 "2023-01-18T10:05:32Z")

</div>

I also found that I must open the sequence manually (after creating it) in the editor before any further manipulation was possible through python -  
OR  
I have to call unreal.LevelSequenceEditorBlueprintLibrary.refresh\_current\_level\_sequence() which also allows further python commands

---

<div class="post-metadata">

**Author:** ![puncted](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@puncted](https://forums.unrealengine.com/u/puncted)\
**Post date:** [May 17, 2023, 9:30pm UTC](https://forums.unrealengine.com/t/knowledge-base-ue4-sequencer-python-cookbook/265097/9 "2023-05-17T21:30:11Z")

</div>

How to get current shot subsequence range from master sequence?

---

<div class="post-metadata">

**Author:** ![arunkc](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@arunkc](https://forums.unrealengine.com/u/arunkc)\
**Post date:** [September 3, 2023, 12:01am UTC](https://forums.unrealengine.com/t/knowledge-base-ue4-sequencer-python-cookbook/265097/10 "2023-09-03T00:01:27Z")

</div>

anim\_section.params.animation = anim\_seq doesn’t reflect the level sequence. I am trying to import an AnimSequence.
