ZBrushCentral

Using the [ShellExecute] command?

Hi,
I am trying to use [ShellExecute] to launch an external python process in Mac OS, as in:

[ShellExecute, “python test.py”]

This does not seem to work as I would expect. Is there a better way to launch shell commands on a Mac than ShellExecute?

Thank you!

You probably need to use the full path but I’ve not tested the ShellExecute on a Mac.

As an alternative, you could use the ZFileUtils LaunchAppWithFile function:
http://docs.pixologic.com/user-guide/customizing-zbrush/zscripting/zfileutils/#launchApp

HTH,
Marcus

Thanks for your reply, Marcus! I see I have encountered quite the expert :smiley:

So forgive me if this is a basic question, as I’m new to this side of things: While the ZFileUtils option certainly looks intriguing, it isn’t clear to me how to get the ZFileUtils plugin installed correctly?

I downloaded the ZFileUtils_4R8_02A/ folder, moved it to my “ZBrushOSX 2020 1.3FL/ZStartup/ZPlugs64/” directory.

To test I copied the [CheckSystem] routine from the doc below to a test file with a call [RoutineCall,CheckSystem] after. The Note “The ZFileUtils plugin DLL could not be found” pops up, so I must have done something wrong.

What step am I missing?

Thank you!!!

referencing doc:
http://docs.pixologic.com/user-guide/customizing-zbrush/zscripting/zfileutils/?_ga=2.76301461.1426938145.1595889640-859862387.1595626987#dllPath

Probably a path issue. Your zscript TXT file and the MyPluginData folder containing the ZFileUtils libraries should be directly in the ZStartup\ZPlugs64 folder. There shouldn’t be a ZFileUtils_4R8_02A folder at all - that is just to contain the files and examples.

ok thanks Marcus, I moved everything into the ZPlugs64/ dir and that got the plugin running. However I’m getting the error code “-1753” when trying to run the FileExecute/LaunchAppWithFile line from the docs as follows:
"
[MemCreate,ZFileUTils_AppPath, 256, 0]
//write app path to memblock
[MemWriteString,ZFileUTils_AppPath,myAppPath,0]
[VarSet,err,[FileExecute,dllPath, “LaunchAppWithFile”,
[StrMerge, "/usr/bin/python ", myPythonFilePath], , ZFileUtils_AppPath]]
[MemDelete,ZFileUTils_AppPath]
"

Any idea what that error code means? Am I using the command wrong? I am using [FileNameResolvePath] to set these path variables before feeding them into the command.

Thanks again!

Again, this is probably a path error. (The code is not specific.) Perhaps there’s a missing forward slash or something. I think I wouldn’t use StrMerge inside the [FileExecute] command - I’m not saying it won’t work but I think it would be better from a debugging point of view to write something like:

[VarSet,myPythonFilePath,[StrMerge, "/usr/bin/python", myPythonFilePath]]
[VarSet,err,[FileExecute,dllPath, “LaunchAppWithFile”,myPythonFilePath, , ZFileUtils_AppPath]]

You could then use [Note,myPythonFilePath] to check the file path is correct. (When copying your code I noticed there’s a space after “python” but that may be the forum putting that in.)

HTH,
Marcus

ok thanks, I am indeed trying to run an outside script as the effective command

“/usr/bin/python /this/path/myPythonFile.py”

but I think as written that was mistaken anyway, the call to /usr/bin/python is implicit in the ZFileUtils_AppPath, so I just need the file to feed the python app the python file I want to execute.

Will have to play with paths and see why I’m not getting it right as I’m writing them. Thanks again for the feedback, Marcus.