cook from python in commandlet, possible?

   1502   0   0
User Avatar
Member
6 posts
Joined: 12月 2017
Offline
Hey
Is it possible to get bake results from python api when running python script as a commandlet?

I'am using a python script based on what is described here:
https://www.sidefx.com/docs/unreal/_public_a_p_i.html#PublicAPIPyAsyncProcessor [www.sidefx.com]
(script at the end)

When running script.py in unreal editor (5.0ea2) itself I get the bake saved.

But if run the scirpt as a commandlet it just runs and no errors but no bare results and no hars spawned no callbacks on ProcessHDAExample called (on_failure or other). That is how I run the script as a commandlet:

#.\UnrealEditor-Cmd.exe "myproject.uproject" -run=pythonscript -script="script.py"
The hda is just a file input sop with file path to bgeo exposed as param.

Thanks in advance.

----------------script---------,
from time import sleep
import unreal
from HoudiniEngineV2.asyncprocessor import ProcessHDA
_g_processor = None

hda_path = '/Game/HDA/import_utils.import_utils'

def make_parameters():
    parameters = {}
    parameter_tuple = unreal.HoudiniParameterTuple()
    parameter_tuple.string_values = ("path to bgeo",)
    parameters['file'] = parameter_tuple
    return parameters    

class ProcessHDAExample(ProcessHDA):
    def on_failure(self):
        unreal.log_error('on_failure!')
        global _g_processor
        _g_processor = None

    def on_complete(self):
        unreal.log_warning('on_complete!')
        global _g_processor
        _g_processor = None

    def on_post_processing(self):
        unreal.log_warning('on_post')



def run():
    # Create the processor
    global _g_processor
    _g_processor = ProcessHDAExample(
        unreal.load_object(None, hda_path), 
        parameters = make_parameters(),
        enable_auto_bake = True,
        bake_directory_path = "/Game/HDA",
        remove_output_after_bake = True,
        replace_previous_bake = True,
        delete_instantiated_asset_on_completion_or_failure = True
        )

    if not _g_processor.activate():
        unreal.log_warning('Activation failed.')
    else:
        unreal.log_warning('Activated!')

    #i = 0
    #while _g_processor:
    #    sleep(5)
    #    i+=1
    #    unreal.log_error("tik tack {}".format(i))


if __name__ == '__main__':
    run()
Edited by pablo_lukaszewicz - 2022年2月11日 12:36:43
  • Quick Links