How to query user selection in the editor?

First post: All new to Unreal, but long time Python & Maya user.

Trying to do something which seems very simple when scripting other DCC apps, but I’m just completely missing it here:

How does one query what the user has selected in the editor, so they can then loop over those actors (like the selected static mesh, if I’m getting my terminology right) executing code? I’ve been pouring over the docs and examples, but can’t find a single thing that seems to showcase this.
Any direction in this area would be appreciated, thanks.


You can use this function:


If you want more info, I have a video showing this command on my Youtube channel :slight_smile:

Thanks for the reply, very appreciated. I’d actually solved it a different way in the meantime, but yours takes a lot more code. This was the other solution I found online:

class EditorUtil(unreal.GlobalEditorUtilityBase):
editorUtil = EditorUtil()
selected = editorUtil.get_selection_set()

Which works. But it seemed like a lot of work: I tried removing things, like the @unreal.uclass decorator, or even the EditorUtil class, and each removal caused it to fail.
Basically, this


Can’t be called to directly.

For my own edification, do you know why you need to make the EditorUtil subclass wrappered with the @unreal.uclass decorator?

I’ll be sure to check out your video’s too, thanks!

BTW @AlexQuevillon : Great video’s, thanks so much for releasing those to the community.