New task nuke file generator

Hello!

I’ve been trying to fold something I’ve been working on into our existing hiero-export system.

In short, the big picture is a sort of nuke script from new task file generator that happens post ingest.
Where you create a new task on shotgrid and it’ll create the nuke script in the correct place and named correctly for the task containing all of the correct nodes from the initial ingest.
The nuke script it creates / copies is a v000 comp script generated at ingest time.

I’ve thought about breaking this down into 2 main tasks.

  1. A version zero script generator, that runs in Hiero as part of the export process.
  2. A new task → script generator, triggered by a menu in shotgrid, or via the events daemon that we already have running.

Through our current ingest process we are using the tk-hiero-export to ingest everything to shotgrid and generate the comp scripts. My thinking was I could tap into this export process and at the point Hiero creates the v001 nuke script I’d want to create an identical v000 nuke script.

I’m just having some trouble finding where to generate the v000.
Should it be generated in the sg-nuke-shot-export / FnNukeShotExporter or a script that runs once the export process completes?
If it’s the latter, is there some sort of ‘hiero_post_export.py’ we can take advantage of?

Thanks in advance for any hints / suggestions to help us along the way!

For anyone following along…
I’ve managed to get the version zero generation part of the system working by modifying the sg_nuke_shot_export.py.
I’ve placed the following code into the finishTask function:

# Get current script path and name
        scriptv1Path = self._resolved_export_path
        scriptv1Name = os.path.basename(scriptv1Path)
        self.app.log_debug(f'Nuke Script v001 Path: {scriptv1Path}')
        # Generate script path and name for version zero
        scriptv0Path = scriptv1Path.replace('.v001.', '.v000.')
        scriptv0Name = os.path.basename(scriptv0Path)
        self.app.log_debug(f'Nuke Script v000 Path: {scriptv0Path}')
        
        #Modify file contents to update nuke root name to v000 and hiero metadata script path tag to v000
        # Read the nuke v001 script
        with open(scriptv1Path, "r") as file:
            nukeScriptv1Data = file.read()
            self.app.log_debug(f'Reading data from: {scriptv1Name}')

        # Swap out any paths inside the nuke script
        nukeScriptv0Data = nukeScriptv1Data.replace(scriptv1Name, scriptv0Name)

        # Write the modified data to a version zero script.
        with open(scriptv0Path, "w") as file:
            file.write(nukeScriptv0Data)
            self.app.log_debug(f'Writing data to: {scriptv0Name}')
        
            self.app.log_debug("Version Zero Sucessful!")

Now onto part 2…
I’ll probably keep this updated should anyone else be looking to achieve the same thing.