# Get All Actors in 3D Level

Something that isn't entirely apparent in Unreal, especially if your work involves Sequencer, is that the obvious function to get all levels in the current Editor World isn't always enough to get every actor in the viewport.

## For Persistent Actors

The most basic function to get the available actors in our 3D Level is [get\_all\_level\_actors](https://dev.epicgames.com/documentation/en-us/unreal-engine/python-api/class/EditorActorSubsystem?application_version=5.3#unreal.EditorActorSubsystem.get_all_level_actors):

```python
EditorActorSubsystem = unreal.get_editor_subsystem(unreal.EditorActorSubsystem)

actors = unreal_systems.EditorActorSubsystem.get_all_level_actors()
```

A shortcoming of this method, if your work involves Sequencer, is that <mark style="color:yellow;">Spawnables are not included</mark>:

<figure><img src="https://368271246-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FStUBkBT2qJGKNkIZ6yc7%2Fuploads%2FqkwoJgpcuothNrv1WvfV%2Fimage.png?alt=media&#x26;token=c550eeef-7398-42f9-aea0-6aa2b3087275" alt="" width="563"><figcaption></figcaption></figure>

***

## Including Sequencer Spawned Actors

This method relies on the fact that Sequencer currently adds a `SequencerActor` tag to any actors it spawns:

<figure><img src="https://368271246-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FStUBkBT2qJGKNkIZ6yc7%2Fuploads%2FoXhyLSlfIPqQIor8QLG3%2Fimage.png?alt=media&#x26;token=6ad88624-e9d7-40ca-9c63-9ef793827e61" alt="" width="419"><figcaption></figcaption></figure>

```python
UnrealEditorSubsystem = unreal.get_editor_subsystem(unreal.UnrealEditorSubsystem)

spawned_actors = unreal.GameplayStatics.get_all_actors_with_tag(
    UnrealEditorSubsystem.get_editor_world(),
    "SequencerActor"
)
```

This will give us a list of any spawnable actors which we can add to our earlier results:

```python
EditorActorSubsystem = unreal.get_editor_subsystem(unreal.EditorActorSubsystem)
UnrealEditorSubsystem = unreal.get_editor_subsystem(unreal.UnrealEditorSubsystem)

def get_all_actors():
    actors = EditorActorSubsystem.get_all_level_actors() or []
    spawned_actors = unreal.GameplayStatics.get_all_actors_with_tag(
        UnrealEditorSubsystem.get_editor_world(),
        "SequencerActor"
    ) or []
    return actors + spawned_actors
```

This updated function will successfully find the Spawnable Actor:

<figure><img src="https://368271246-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FStUBkBT2qJGKNkIZ6yc7%2Fuploads%2F4wmrNlkBxNAlX0EOBNV1%2Fimage.png?alt=media&#x26;token=dd9a830e-6646-4eef-8807-b360e5fceefb" alt="" width="563"><figcaption></figcaption></figure>

***

## Expanded Options

From a pipeline perspective we might want the ability to separate Spawnable (Sequencer) actors from Possessable (Persistent Level) actors. This convenience function supports each posibility:

```python
EditorActorSubsystem = unreal.get_editor_subsystem(unreal.EditorActorSubsystem)
UnrealEditorSubsystem = unreal.get_editor_subsystem(unreal.UnrealEditorSubsystem)

def get_all_actors(include_possessables = True, include_spawnables = True):
    """
    Get the list of Actors in the current Editor World / 3D Level
    
    parameters:
        include_possessables (bool): whether to include Persistent Level actors
        include_spawnables (bool): whether to include Sequencer Spawned actors
    
    """
    actors = []
    if include_possessables:
        actors += EditorActorSubsystem.get_all_level_actors() or []
    if include_spawnables:
        actors += unreal.GameplayStatics.get_all_actors_with_tag(
            UnrealEditorSubsystem.get_editor_world(),
            "SequencerActor"
        ) or []
    return actors
```

<figure><img src="https://368271246-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FStUBkBT2qJGKNkIZ6yc7%2Fuploads%2FTGsVnbE0k7q5Qb3ZHkvH%2Fimage.png?alt=media&#x26;token=b5de8b5e-f303-4100-bae1-761e82a93667" alt=""><figcaption></figcaption></figure>
