Originally Posted by Kwramm
getting my hands dirty with C++ and ZScript and managed to write a C++ DLL which I can load in a ZScript with FileExecute.... which then continues to host a .NET CLR with a loaded C# dll, which then launches a Python script (we use the same C# dll from Max).
C# talks to Python via ZMQ (thanks to Rob Galanakis for mentioning ZMQ). For the RPC calls JSON-RPC is used.
So far I can launch a Python script from ZBrush, cpp, Python, 3ds Max, Photoshop Extendscript and then call remote procedures either from Python or from the host app. Still working on ZBrush now - so far it's just one-directional communication, until I figure out if I can use the Sleep command for polling.
The idea is to have a universal communication library for RPC calls to a Python script which is launched by a host app. E.g. we can then put all the business logic of statistics, QA or file management scripts into python. Or we can just extend the app itself using Python.
Anyway, there's little to show as it's just a bunch of DLLs and scripts with text output, but if someone is crazy enough to attempt something similar... just ask
There was an undocumented function of the ZfileUtils.dll
that allows you to launch any kind of program or pyhton script. I found the function while inspecting the dll with some tools, hehe.
I can't remember the function right now, but once I get home I'll let you know! I'm not sure how happy Pixologic will be about it!
I used to launch UVLayout from within Zbrush and send the meshes to the program.
I don't think you'll be able to use the sleep command for much other than "freezing" Zbrush for a some time. The way I handle bi-directional communication is to bind a Zscript to a specific hotkey.
This zscript will then load the contents of a txt file and evaluate them on runtime. This way you don't need to compile the script on zbrush startup and you can change the commands that you want to be evaluated on-the-fly in the txt.
So in order to run a command from an external application what you need to do is to change the TXT file and then send the hotkey combination to the Zbrush window so that the zscript starts.