Different behaviors of running scripts from Editor and Commandlet?

Running the following script in the Editor, I see the target objects selected in the Content Browser.

import unreal as ue

toselect =     

However, running the same script from commandlet, nothing happens in the Editor, except that a console window briefly shows up as screenshot below.

What’s different when calling the commandlet? Am I missing anything obvious?

A commandlet is a console environment, and the window you see pop-up is the commandlet process starting, running the Python script, and then exiting.

Commandlets have no Slate UI, so there is no Content Browser to sync the selection of.

@JamieDa1y Thanks Jamie. Glad to have an authority here!

My further question:

Is it possible to activate Content Browser from commandlet, or any other approach, so that I can invoke things in the browser such as sync_browser_to_objects()?

Commandlets cannot have Slate UI, and the Content Browser requires a Slate UI, so no, you cannot spawn a Content Browser inside a commandlet.

What are you trying to do here?

What I’m trying to do: Select linked raw assets in another app, and one-click later, the linked (imported) .uassets are selected in the active UE instance’s Content Browser. I can run an external program from that app, e.g., a commandlet.

I wish there were RPC support in UE.

4.23 will add support for Python remote execution, so you’ll be able to find any running editor instances on your local machine and execute Python on them.

We provide a Python implementation of the client side of remote execution (which is also the reference implementation if you wanted to port it to another language), and this works in any Python interpreter with no unreal dependency (we use it from our art tools, and things like Maya).

It sounds like that could help you here?

Oh, awesome! Exactly what I need. Can’t wait to have that.

How come? It’s very interesting.