run a python script in Unreal after HDA cooks VAT assets

   3369   2   0
User Avatar
Member
43 posts
Joined: May 2013
Offline
Is there an easy way to run a python script in Unreal after an HDA is finished cooking? I see options from the Houdini side, but I want to automate the Unreal setup after the VAT ROP is run in an HDA - import the pos and rot textures, import the fbx, set up the material instance, etc. I know that VAT 2.1 has some scripts, and I'm using the materials that have been provided, but I want to run the setup from a python script, since it's basically the same steps every time.
User Avatar
Member
7 posts
Joined: Dec. 2018
Offline
I have done this before by using unreal's remote control api. This allows you to control unreal from a web request.
https://docs.unrealengine.com/en-US/ProductionPipelines/ScriptingAndAutomation/WebControl/QuickStart/index.html [docs.unrealengine.com]

The method I have done is to have a houdini pyhton node at the end that makes a request (request module) that unreal is listening for. And I specifically target the pyhton interp in unreal. Here is a little example of what that could look like from hoduini.


payload = {
            "objectPath": "/Script/PythonScriptPlugin.Default__PythonScriptLibrary",
            "functionName": "ExecutePythonCommandEx",
            "parameters":
                {
                    "PythonCommand": "import my_module\nmy_module.func('{0}')".format(string_arg)
                }
        }

        result = requests.put(UNREAL_ENDPOINT, json=payload)


its a little hacky but has worked well for us
Edited by adam_perin - March 31, 2021 14:25:48
User Avatar
Member
6 posts
Joined: Feb. 2022
Offline
adam_perin
I have done this before by using unreal's remote control api. This allows you to control unreal from a web request.
https://docs.unrealengine.com/en-US/ProductionPipelines/ScriptingAndAutomation/WebControl/QuickStart/index.html [docs.unrealengine.com]

The method I have done is to have a houdini pyhton node at the end that makes a request (request module) that unreal is listening for. And I specifically target the pyhton interp in unreal. Here is a little example of what that could look like from hoduini.


payload = {
            "objectPath": "/Script/PythonScriptPlugin.Default__PythonScriptLibrary",
            "functionName": "ExecutePythonCommandEx",
            "parameters":
                {
                    "PythonCommand": "import my_module\nmy_module.func('{0}')".format(string_arg)
                }
        }

        result = requests.put(UNREAL_ENDPOINT, json=payload)


its a little hacky but has worked well for us

Hey Adam,

I've been using this method as well for a while and it works great. However, I have an issue with this method where it doesn't let me rebuild 2 HDAs that use this command at the same time. Unreal Engine would freeze. I'm guessing because the command doesnt run asynchronously.
Did you have the same issue? And did you find a way around it?

Thanks!
Edited by Skawt - May 25, 2023 09:16:05
  • Quick Links