Custom File Path Location to Save when Launching Mocha through Nuke

I’m using MochaPro 2020.5 version7.5.1 and Nuke 12.2v3

Also using the python code provided by Boris FX to launch Mocha through Nuke: Boris FX | Mocha Extras

I’m trying to set the Project Location to a custom file path without using Mocha’s python API. I have the variable set up and just have to assign it correctly when Mocha launches, but I have been unable to figure it out.

On the current code, it looks like the variables are set on a list:

cmd = [self.mocha_path, ‘–in’, in_point, ‘–out’, out_point, ‘–frame-rate’, frame_rate, filepath]

        err = subprocess.Popen(cmd) #open mocha with the project file as a separate process
    except subprocess.CalledProcessError, e:
        print "Ping stdout output:\n", e.output

    return err

I’ve tried to insert “–project_file”, “–location”,"–loc","–l", “–path_dir” but nothing seems to work.

What would be the right way to set up a custom project location to save?


Let me poke @martinb about this as he knows quite a bit more of the Python side of things than I do.

For a start I’d recommend updating to this version: (131.6 KB)

New projects are defined by the movie filepath given to them, so the only way to alter this would be to set your default Absolute path in output directory to the custom one via preferences.
The absolute path would then always save new mocha projects to this location:

If you want to customize it every time based on the footage, you would need to do something more sophisticated.

Thank you for the quick support!

And thanks for the updated script.

Yeah I’d want to customise it every time based on the shot number. I already have the variable with the directory I want to save to. So I’m guessing this is not possible to adapt on the nuke function that launches Mocha? Only through Mocha API?

Thanks for your time

Yes, your best option would be to adjust the in Mocha to address settings based on the filename coming in. I’ve not tried this personally, so it may not be possible to catch the new file being loaded before is initialised.

If you need help on how to setup the output directory via Python I can point you in the right direction.
An alternative approach would be to use the script to set the output preferences by editing the preferences file itself on runtime.