Bootstrap Chameleon Logo

Most used Editor APIs

Editor APIs MVP

In a real-world project, I have counted the occurrence of Editor APIs, and the following 100 APIs are definitely the MVPs in Unreal Python.

TIP
The APIs below starting with unreal.Python...Lib and unreal.ChameleonData are TAPython extension APIs, while the others are UE built-in APIs.

Interaction

When writing editor tools, interaction-related APIs are the most commonly used, such as pop-ups, message prompts, logs, notifications, file dialogs, and more.

The numbers before the API indicate the frequency of use, with larger numbers indicating more frequent use.

  • 199:unreal.log_warning

Outputs warning information in the console.

  • 94: unreal.PythonBPLib.notification

Popup notifications are a user-friendly way of notifying non-developer users.

  • 43: unreal.PythonBPLib.get_chameleon_data

Find the corresponding ChameleonData through the tool path to locate the instance of Tool B in Tool A, modify its content, etc.

  • 34: unreal.log
  • 32: unreal.log_error

Outputs log and error information in the console.

  • 28: unreal.PythonBPLib.confirm_dialog

Displays a confirmation dialog.

  • 13: unreal.PythonBPLib.open_file_dialog

Opens a file dialog.

  • 8: unreal.PythonBPLib.message_dialog

Displays a message dialog.

  • 6: unreal.ChameleonData.get_chameleon_window_size

Gets the size of the Chameleon window.

  • 4: unreal.PythonBPLib.set_clipboard_content

Sets the content of the clipboard.

  • 3: unreal.PythonBPLib.open_directory_dialog

Opens a directory dialog.

  • 3: unreal.ChameleonData.set_chameleon_window_size

Sets the size of the Chameleon window.

  • 2: unreal.ChameleonData.request_close

Closes the Chameleon window, used in the main tool to close other Chameleon tools, etc.

  • 2: unreal.ChameleonData.snapshot_chameleon_window

Captures the content of the Chameleon window interface and saves it as a PNG image.

Assets

The following includes asset-related APIs, such as loading assets, getting assets of a specific type, saving assets, deleting assets, importing assets, and more.

  • 105: unreal.load_asset

Loads an asset from a path.

  • 26: unreal.EditorAssetLibrary.does_asset_exist

Checks if an asset exists.

  • 25: unreal.EditorAssetLibrary.save_asset

Saves an asset at a specified path.

  • 11: unreal.AssetToolsHelpers.get_asset_tools

Gets Unreal's AssetTools, which perform many asset-related operations, such as create_asset, duplicate_asset, export_assets, and rename_assets.

Gets AssetDatas of a specific type of asset, such as getting all level assets ("World") or all material instances ("MaterialInstance").

  • 4: unreal.EditorAssetLibrary.delete_asset

Deletes an asset at a specified location.

  • 3: unreal.EditorLoadingAndSavingUtils.save_dirty_packages

Saves all dirty (modified but unsaved) assets.

  • 3: unreal.AssetToolsHelpers.get_asset_tools().import_asset_tasks

Sets up an import asset task.

  • 3: unreal.PythonBPLib.get_selected_assets_paths

Gets the paths of the currently selected assets.

  • 3: unreal.EditorAssetLibrary.duplicate_loaded_asset

Duplicates a loaded asset.

Level/World

Level and World are also objects that we often need to operate on in the editor, such as getting the current level, getting the current World, saving the current level, loading levels, and more.

  • 24: unreal.EditorLevelLibrary.get_editor_world

Gets the current editor World for UE4.

  • 23: unreal.EditorLevelLibrary.set_selected_level_actors

Gets all currently selected Actors.

  • 14: unreal.get_editor_subsystem(unreal.UnrealEditorSubsystem).get_editor_world

Gets the current editor World for UE5.

  • 11: unreal.EditorLevelLibrary.save_current_level

Saves the current level.

  • 10: unreal.EditorLevelLibrary.load_level

Loads a level from a path.

  • 9: unreal.EditorLevelLibrary.save_all_dirty_levels

Saves all dirty (modified but unsaved) levels.

  • 8: unreal.PythonLevelLib.get_levels

Gets all levels in a specified World.

  • 7: unreal.SystemLibrary.get_project_directory

Gets the path of the current project.

  • 4: unreal.EditorLevelUtils.add_level_to_world

Adds a level to the current World.

  • 4: unreal.EditorLevelLibrary.set_current_level_by_name

Sets the currently active level by name. You can get all levels through get_levels and then activate a specific level using set_current_level_by_name.

Viewport

Viewport-related APIs allow us to modify things in the current viewport, such as the camera.

  • 10: unreal.PythonBPLib.get_level_viewport_camera_info

Gets the position and rotation of the current scene camera.

  • 9: unreal.PythonBPLib.get_viewport_pixels

Gets the pixel content of the current viewport. For example, this API is used when sending viewport content to other tools like stable-diffusion.

  • 7: unreal.PythonBPLib.viewport_redraw

Forces a redraw of the current viewport. For example, if we modify the object observed by the camera in the viewport and want to capture the viewport content, we need to ensure that the content in the viewport is updated by calling this viewport_redraw before capturing.

  • 4: unreal.PythonBPLib.set_level_viewport_is_in_game_view

Sets the viewport display to 'game mode', equivalent to the shortcut key G in the editor state.

  • 4: unreal.PythonBPLib.set_level_viewport_camera_info

Sets the position and rotation of the current scene camera.

Selections

The following APIs are related to selections, such as getting the currently selected Actor, getting the currently selected assets, setting the currently selected assets, and so on.

  • 13: unreal.PythonBPLib.select_actor

Selects a specific Actor in the editor.

  • 9: unreal.PythonBPLib.set_selected_assets_by_paths

Selects assets at a specific path in the Content Browser.

  • 6: unreal.PythonBPLib.set_selected_folder_path

Sets the object selected in the World Outliner to a specific Folder. Note that the Folder here refers to the Folder in the Outliner, not the Content Browser.

  • 5: unreal.get_editor_subsystem(unreal.EditorActorSubsystem).get_selected_level_actors

Selects a specific Actor in the editor, used in UE5.

  • 5: unreal.PythonBPLib.select_none

Deselects all Actors.

  • 4: unreal.EditorLevelLibrary.get_selected_level_actors

Selects a specific Actor in the editor, used in UE4.

TIP
Here, we notice that multiple APIs have similar functions, such as: unreal.PythonBPLib.select_actor, unreal.get_editor_subsystem(unreal.EditorActorSubsystem).get_selected_level_actors, unreal.EditorLevelLibrary.get_selected_level_actors are all for selecting specific Actors.
The reason for this is that TAPython started development in the UE4.21 version, and gradually added some APIs that were not in the engine at the time (or I didn't know), and also, as UE5 gradually migrates various EditorLibraries into various Subsystems, it results in duplicate APIs.

Actor/Component

APIs related to Actors and Components in the scene.

  • 13: unreal.PythonBPLib.get_objects_by_class

Gets all objects of a specific type in the editor.

  • 19: unreal.PythonBPLib.spawn_actor_from_class

Creates an Actor from a specific class, such as spawning a unreal.StaticMeshActor during creation.

Gets all Actors in the current editor.

  • 10: unreal.PythonPhysicsAssetLib.get_selected_bodies_indexes

Gets the indexes of all bodies in the currently selected physics Asset.

  • 10: unreal.PythonBPLib.add_component

Adds a Component to a specific Actor. For example, adding a unreal.StaticMeshComponent to an Actor.

  • 8: unreal.PythonBPLib.find_actor_by_name

Gets the Actor with the specified ID Name. Note that this is the ID Name, not the Actor's Label Name.

  • 7: unreal.PythonBPLib.spawn_actor_from_object

Creates (copies) a specified Actor into the scene.

  • 5: unreal.PythonBPLib.get_selected_components

Gets all currently selected Components.

Query/Modify

A large part of UE objects in the editor is accessed and modified using get_editor_property and set_editor_property. Various EditingLibraries also provide operations for modifying resources, objects, etc. In addition to these, TAPython also provides some APIs for getting and setting properties. Of course, if you need more or specific APIs, you can add them yourself.

  • 37: unreal.MaterialEditingLibrary.connect_material_expressions

Connects two nodes in a material.

  • 22: unreal.MaterialEditingLibrary.create_material_expression
  • 17: unreal.MaterialEditingLibrary.create_material_expression_in_function

Adds a material node in a material/material function.

  • 15: unreal.MaterialEditingLibrary.set_material_instance_scalar_parameter_value
  • 13: unreal.MaterialEditingLibrary.set_material_instance_texture_parameter_value
  • 12: unreal.MaterialEditingLibrary.get_texture_parameter_names

Sets/Gets scalar and texture parameters in a material instance.

  • 10: unreal.PythonStructLib.add_variable

Adds a variable to a UserDefinedStruct.

  • 10: unreal.MaterialEditingLibrary.get_scalar_parameter_names

Gets the names of all Scalar parameters in a material.

  • 8: unreal.PythonStructLib.get_variable_names

Gets the names of all variables in a UserDefinedStruct.

  • 7: unreal.PythonTextureLib.set_render_target_data

Populates data in a RenderTarget (modifies RenderTarget).

  • 6: unreal.PythonDataTableLib.get_row_names

Gets the names of all rows in a DataTable.

  • 6: unreal.PythonMaterialLib.set_static_switch_parameters_values

Sets the values in a specified StaticSwitch in a material.

  • 5: unreal.MaterialEditingLibrary.get_material_instance_texture_parameter_value

Gets the value of a specified Texture parameter in a material instance.

  • 4: unreal.PythonPhysicsAssetLib.get_bodies_from_bone

Gets all bodies on a specified bone in a physics asset.

  • 4: unreal.PythonStructLib.remove_variable_by_name

Removes a variable with a specified name from a UserDefinedStruct.

  • 4: unreal.PythonStructLib.add_directory_variable

Adds a new dictionary-type variable to a User Defined Struct.

Gets all textures used in a material (does not retrieve textures that exist in the material but are not connected).

  • 4: unreal.PythonMaterialLib.get_static_switch_parameter_values

Gets the static switch info of a specified material, including whether it's overridden, etc.

  • 4: unreal.PythonDataTableLib.set_property_by_string_at

Sets the content at a specified location in a DataTable.

  • 4: unreal.PythonDataTableLib.get_shape

Gets the "row and column" information of a specified DataTable, excluding the title and row names.

  • 4: unreal.PythonDataTableLib.get_column_names

Gets the names of all columns in a specified DataTable.

  • 4: unreal.MaterialLibrary.set_scalar_parameter_value

Sets the value of a specified Scalar parameter in a material.

  • 3: unreal.MaterialEditingLibrary.layout_material_expressions

Automatically lays out nodes in a material.

  • 3: unreal.MaterialEditingLibrary.recompile_material

Recompiles a material.

  • 3: unreal.PythonPhysicsAssetLib.set_body_rotation

Sets the rotation value of a specified body in a physics asset.

  • 3: unreal.PythonStructLib.get_guid_from_property_name

Gets the GUID of a specified variable in a User Defined Struct by PropertyName. This GUID is used in APIs such as unreal.PythonStructLib.rename_variable to specify the variable to be modified.

  • 3: unreal.MaterialEditingLibrary.set_material_instance_vector_parameter_value

Sets the value of a specified Vector parameter in a material instance.

  • 3: unreal.MaterialLibrary.set_vector_parameter_value
  • 3: unreal.MaterialEditingLibrary.get_vector_parameter_names

Gets/Sets the names of all Vector parameters in a material.

  • 3: unreal.MaterialEditingLibrary.get_material_instance_scalar_parameter_value

Gets the value of a specified Scalar parameter in a material instance.

  • 3: unreal.PythonDataTableLib.add_row

Adds a row to a DataTable.

  • 3: unreal.PythonDataTableLib.set_property_by_string

Sets the content at a specified location in a DataTable.

  • 3: unreal.PythonEnumLib.get_enum_len

Gets the length of a specified Enum.

  • 3: unreal.MaterialEditingLibrary.set_material_instance_parent

Specifies the parent material of a material instance.

  • 3: unreal.MathLibrary.make_rot_from_yz

Constructs a Rotator from the Y and Z axes.

  • 3: unreal.PythonLandscapeLib.add_adjacent_landscape_proxy

Creates a new LandscapeProxy in the specified direction of a terrain.

Misc

Below are some miscellaneous APIs that are very useful when writing editor tools:

  • 51: unreal.ScopedSlowTask

Used to add a progress bar for time-consuming tasks.

  • 12: unreal.PythonBPLib.exec_python_command

Executes Python commands through a string, and can specify whether these Python commands should be forced to execute in the GameThread in child threads.

  • 10: unreal.get_editor_subsystem

Gets the Editor Subsystem. Common SubSystems include: EditorActorSubsystem, AssetEditorSubsystem, LayersSubsystem, UnrealEditorSubsystem, ImportSubsystem, EditorValidatorSubsystem, and more.

  • 8: unreal.ScopedEditorTransaction

Used to support Undo and Redo functionality in the editor for subsequent operations.

  • 6: unreal.PythonBPLib.execute_console_command

Executes debugging commands in the Cmd through a string.

  • 5: unreal.PythonBPLib.gc

Forces UE garbage collection.

  • 5: unreal.GuidLibrary.parse_string_to_guid

Converts a string to a Guid format. For example, "A92FC5D4442EF780C79EB49C16F7250E" is converted to a Guid.

  • 4: unreal.PythonBPLib.get_all_deps
  • 3: unreal.PythonBPLib.get_all_refs

Gets all dependencies and references of a specified object.

  • 3: unreal.PythonBPLib.get_modifier_keys_state

Gets the currently pressed modifier keys, such as Shift, Ctrl, Alt, etc.

  • 3: unreal.register_slate_post_tick_callback

Registers a Slate Post Tick callback, which will be executed in the Slate's Post Tick.

Reference

How to manipulate User Defined ENum, Struct, DataTable with Python in Unreal Engine

Manipulate Material Expression Nodes of Material with Python in Unreal Engine

Modify SImage content and Set Pixels to RenderTarget in Unreal Engine