Announcement

Collapse
No announcement yet.

Different behaviors of running scripts from Editor and Commandlet?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    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.

    Code:
    import unreal as ue
    
    toselect = [    
        '/Game/Path/To/My1',    
        '/Game/Path/To/My2',    
    ]  
    ue.EditorAssetLibrary.sync_browser_to_objects(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?
    Attached Files
    Last edited by kakyoism; 04-24-2019, 02:50 AM.

    #2
    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.

    Comment


      #3
      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()?

      Comment


        #4
        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?

        Comment


          #5
          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.

          Comment


            #6
            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?

            Comment


              #7
              Oh, awesome! Exactly what I need. Can't wait to have that.

              Comment

              Working...
              X