Add->Actor To Sequencer as C++ code

What is the C++ code for the menu action Sequencer->Add->Actor To Sequencer?

I tried

ActorGUID = scene->AddPossessable(ActorName,actclass);

to add an actor which exists in the level.
But this gives me a red label of the actor name (=ID) on the track, saying:
“The object bound to this track is missing”

Does this error appers when actor exists?

You’re pretty close. You also need to get the movie scene sequence and bind the possessable, in your case something like this:

MovieSceneSequence->BindPossessableObject(ActorGUID, *Actor);

Seems not to be enough, its still red, when I BindPossessableObject to my LevelSequence.
Maybe its a better idea, to use FLevelSequenceEditorToolkit::AddActorsToSequencer(AActor*const* InActors, int32 NumActors).
How would I create or get this toolkit?

You dont create it, you use once that are open. You can access it via

FLevelSequenceEditorToolkit::OpenToolkits 

or

IterateOpenToolkits(TFunctionRef<bool(FLevelSequenceEditorToolkit&)> Iter);

Note that this is editor code and so this will work only in editor and you need to make you module editor only or put code using this APIs under

#if WITH_EDITOR
//stuff here
#endif

or else you will have errors in packageing

@anonymous_user_f5a50610
Thanks, it’s Editor-only code, so no problem. :slight_smile:

I tried your suggestion and added “LevelSequenceEditor” to my module names but get a linker error:
Error: Couldn’t find parent type for ‘AnimationConduitGraphSchema’ named ‘UEdGraphSchema_K2’ in current module or any other module parsed so far

‘UEdGraphSchema_K2’ is in “BlueprintGraph”, so I added this module, too.
But this didn’t help, same error.

Which modules are needed to solve this error?

can you show your code where you refrence that?

I want to add an actor to the sequencer in C++.
Don’t understand, why every simple step which is already implemented in an editor menu or blueprint is so hard to do in C++.
I gave up here, thanks for helping @anonymous_user_f5a50610.

I did it like this:

ULevelSequence *LevelSequence; 
AActor *Actor;
FGuid Guid;
Guid = LevelSequence->MovieScene->AddPossessable(Actor->GetActorLabel(), Actor->GetClass());
LevelSequence->BindPossessableObject(Guid, *Actor, Actor->());
2 Likes

@aleks_allright
Thanks, that’s what I did. I tried again and it now is actually working. Don’t know what the problem was, probably sth to do with the actor’s label.

This is a funny signature problem for someone who just want to get a toolkit.

static void IterateOpenToolkits(TFunctionRef<bool(FLevelSequenceEditorToolkit&)> Iter);