4.19 Python Editor Scripting

I really would love to know, where I find any informations about the python editor scritping?
It was mentioned at the GDC livestream from the Rigging presentation (before live link presentation started), that the python editor scripting is available now.
So I’m able to find the plugin for sure… but is there any guide how this is supposed to be used at all?

There’s not really any official documentation right now as it’s still pretty early days. The tl;dr would be that anything Blueprint exposed (including your own stuff) is also exposed to Python (with type prefixes removed, and properties/functions converted to snake_case), so if you could do it for a Blueprint, then you should be able to do it in Python.

You can open up the Output Log after enabling the plugin and switch it to “Python” mode (the default is “Cmd” mode) to make working with Python easier. Here you can execute literal Python script, or execute a .py file that exists in any Content/Python folder. All exposed types have valid doc-strings (so work with the “help” command), but finding things can still be a bit tricky.

The plugin is still changing a lot, and certain things will be missing (so much has been added already since 4.19 branched), but please feel free to try it out and provide feedback, or let me know if you have any specific questions.


[USER=“2003”]Jamie Dale[/USER] I’m playing with the python editor scripting in unreal engine, however I can’t figure out how to do a Import FBX file using python.
Do you have some guidelines to do that ?

Thank you

@MaelCo Sadly support for importing (and exporting) assets via Python (and Blueprints) only went in within the past few weeks, so you’ll have to wait for 4.20 for that (or write a custom Blueprint exposed function to handle it).

Translucent is the default for materials with an alpha at import. We have to manually change all of them to Blend Mode: Masked. Can you use Python to get a list of materials in the content library and change them all with a loop?

@WM3dteam Yeah, you should be able to do something by using the asset registry (see unreal.AssetRegistryHelpers.get_asset_registry) to find assets under a certain path (you can use unreal.AssetRegistryHelpers.get_asset if you need to load them).

The blend mode property on the material is BlueprintReadOnly which makes it read-only to scripting (so my_mat.blend_mode = unreal.BlendMode.BLEND_MASKED wouldn’t work), but you can use the set_editor_property helper to bypass that (since the property is also set to EditAnywhere). my_mat.set_editor_property(“blend_mode”, unreal.BlendMode.BLEND_MASKED).

Just in case you want to taste how it is working in UE4 using Python before native support comes in from early access:

Have been playing with this plugin, and might say it helps a lot with automation. Pretty robust features to import and setup your assets (including Materials, AnimationBPs etc). Check out their import assets guide, quite impressive.

ps. You also can embed Python interpreter in your project, which allows you to write game logic with it as well, or expose python console to the player or some other crazy stuff. :slight_smile:

Question: What is the “roadmap” when it comes to native Python support in UE4? Is (and will be) the focus solely on using Pyhtin within the editor, for working with assets and stuff like that, or are there also plans to make Pyhton available during gameplay, like as addon to gameplay scripting via Blueprint?

No current plans for non-editor support.

The glue generation relies on editor-only meta-data, so we’d have to have a UHT plugin dump out the meta-data we need in a blob we could load, and that has issues for extensibility in launcher builds (and is partly why we moved away from UHT glue generation for Python).