ZBrushCentral

Execute python script

Hi,

I need to run python script through command line with some arguments. But I didn’t find anything in documentation/forums that could help.
Do I need to write my own dll, or did I miss something?

Thank you

No, ZBrush can’t handle Python scripts.

Thank you

it still possible but python will be executed out of zbrush, so you need a plugin that can execute python script, than you would have to delay the process to read the python data.
I don’t think there is anything to exploitable using python script even for automate task when you export stuff like 3d models and textures maps :slight_smile:

@faceless

Thank you for your suggestion. All I need is an access to command prompt so I could execute python script. I was thinking about writing my C++ .dll for command prompt access and from ZScript use FileExecute command to run python command through that dll.

If there is an easier way please tell me. I don’t have much experiences with coding in ZBrush.

You might be able to use the LaunchApp function of the ZFileUtils:
http://docs.pixologic.com/user-guide/customizing-zbrush/zscripting/zfileutils/#launchApp

@marcus_civis

Well, when I am thinking about it…if I make python script standalone executable, write arguments into temp text file and then open that executable with text file using LaunchAppWithFile…it could work, I think.

Thank you

Hey Braffe, Marcus gave you the right way to go with LaunchApp function, you can even create batch files and then run with cmd and or unix command line, that what i did on my project :slight_smile:

@faceless

Thank you for confirmation ;). However, I still gonna have figure out how exactly is the file passed into that launched app. I hope that I could get it through sys.argv

mrland

I managed to run python script and pass arguments to it from zbrush by writing and then executing .bat file from zcript using

[FileExecute, dllPath, LaunchAppWithFile, BAT_PATH]

i don’t know what could be a most correct answer
you just create a plugin with an ui, if the python parameters depends of the button state, so you can customize the batch file you can write from zbrush onto you hard drive.
using :
MemCreate
MemWriteString
MemSaveToFile

then you must to have python installed (ex: c:/python27/)
python interpreter must to be define on windows env vars to found the bin directory within python installation.
then in you batch you start like that :

python -c command [arg] …

have a look at the page for more detail :

https://docs.python.org/2/tutorial/interpreter.html

then you just execute your batch file from Zbrush like Marcus, myself and Braffe suggest you to do it with LaunchAppWithFile.

Hi

I am quite curious how you got to pass a paramater or variables to the python script?

Thanks

@cnever
create string that will as batch command execute python script with arguments. Save that string to .bat file. Then execute that file. Alternatively save variables to external text file and then just start python script and make that script to look into text file.

Here is good example: http://www.zbrushcentral.com/showthread.php?165443-GoUVLayout-GoZ-for-UVLayout

@Braffe Thanks for the reply.

I get zbrush to launch the cmd.exe to run the python file but it doesn’t actually run python file just opens the cmd window

Any chance you can explain a little more in detail. The py file runs on its own and so does my .bat file - Just when called via button in zbrush does just the cmd prompt window appear.

thanks

** edit I got it to work or at least to try and run the python file still some figuring out to do so if you want can still share your wise wisdom - It opens cmd prompt but at wrong file location and doesn’t seem to point to right folder etc. so naturally get a error can’t find the .py file.