If you are a Unreal Studio user, you will have access to an additional utility that provides API that are simpler in their utilisation and test a lot of edge cases for you.
Although you can do pretty much everything you need with Python in the free version of the Unreal Engine, some operations can require quite complicated scripts to be made. For example, renaming an asset could require knowledge of the internal code of Unreal Engine 4 that goes beyond doing a simple string change.
Enable the “Editor Scripting Utilities Plugin”
Make sure the plugin entitled Editor Scripting Utilities
is enabled in your project.
Additional Libraries Provided by the Editor Scripting Utilities Plugin
The following libraries are available.
Tip:to list all methods and properties, use the help command as follows:
In Unreal Engine 4, an asset needs to be loaded before utilization. This library lets you load, save, rename etc. assets contained in the Content Browser.
Note: Once an asset is loaded in Unreal Engine 4, it will be loaded in memory until the editor is closed.
In collaboration with unreal.EditorLoadingAndSavingUtils, unreal.EditorLevelLibrary let you modify, spawn, destroy actors from a level.
You can also create and save levels in your project.
A library of functions to filter a list of actors and objects by name, tag, class, etc.
Run Python as a command line argument
With the plugin EditorScriptingUtilitites you can use 'ExecutePythonScript=' with the command line argument which will wait for the Editor to be fully loaded and idle before running the Python script.
This can be useful if you need to perform scripting operations on objects that are on a level that can take a while to load.
UE4Editor-Cmd.exe MyProject.uproject ExecutePythonScript="c:\my_script.py"