Question: Communicating with ZBrush outside of ZBrush, or multi-plugin workaround
I am just starting out with ZBrush and ZScript, so I am sorry if my questions are a bit noobish. I have tried searching around for these answers, but can't seem to find them.
1. Can you launch ZBrush with command line arguments, such as making ZBrush run certain plugins/scripts once launched?
2. Can a program outside of ZBrush tell ZBrush to run different plugins/scripts/save/anything?
The reason I ask these is because I am trying to write a script that does several different steps automatically. However, some of these steps use other plugins, and I have heard that only one plugin can be run at a time (so if you call another plugin, your plugin will stop). Why is this? Does ZBrush have any plans to better support pluggins? Is there a way to work around this at all? Are the UV Master, Dynamesh(something like that), and 3D print exporter that come with ZBrush open source plugins that I can just yoink the code from and run instead?
I would really rather use ZBrush for all of this, instead of needing to jump between ZBrush and Maya, or worse yet, write GUI bound code to get this all automated...
Thanks for any help!!
Last edited by DoctorWhy; 09-26-12 at 10:38 PM.
You can't control ZBrush from the command line beyond launching it with a file. You can write an executable (or for that matter, a DLL) that launches ZBrush with a zscript but I don't know if you could launch more than one zscript this way. The Windows code would be something like:
static const char *zbrushFolder = "C:\\Program Files (x86)\\Pixologic\\ZBrush 4R3";
static const char *zbrushExe = "zbrush.exe";
static const char *scriptPath = "C:\\Users\\Mark\\Desktop\\TestZScript.zsc";//if just a file name then ZBrush will look in the default location 'ZScripts'
WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
ShellExecute(NULL, "open", zbrushExe, scriptPath, zbrushFolder, SW_SHOWNORMAL);
Is it possible to pass parameters to other plugins either through that method, or through another script, such as the size in inches for the 3D printing plugin?
Thanks for the reference, but can you tell me what I am suppose to be looking at in order to help answer my question? Sorry, I am not the one doing this plugin, and know very little of ZScript at the moment. So I am still getting use to the ZScript terms and whatnot, so sorry if this is a stupid question. I am just trying to figure out if ZScript is the proper route to take before jumping in.
Last edited by DoctorWhy; 09-27-12 at 11:43 AM.
I think you might be able to repeatedly load a zscript text file (writing the necessary commands on the fly) but you will have to test that. You can't do it through a zscript directly because setting any option for another plugin immediately passes control to that plugin.
Originally Posted by DoctorWhy
Let me make sure I understand this. I can write the lines that need to be executed to set certain parameters on the fly (using my external program), then, using the method you posted above (if it does work with launching more than 1 zscript), call that file that sets certain parameters, waits a certain amount of time, then redoes this over and over, and then tells a certain plugin to start working, waits, then repeat until all the plugins are done. Then calls 1 last zScript to save? That will probably work if it does work this way.
Originally Posted by marcus_civis
If you know the steps required you could record them as a macro, that might help.
I would love to use this approach, but don't know, at all, if it would work. It really depends on how macros are recorded and how the ability to use them work, or if they suffer from other problems.
Originally Posted by Doug Jones
Last edited by DoctorWhy; 09-27-12 at 04:35 PM.
Yes, that's it.
Originally Posted by DoctorWhy
A macro will not work for the same reason as a single zscript will not work - a macro is just another type of zscript and will lose control the moment a plugin is called (even if it is simply setting an option on the plugin interface).
[Edit: Actually NO - see below!]
Well, it turns out I was wrong. It IS possible to set multiple zplugin interface items from another zscript, so you can certainly set things from a single zscript. Not sure when that became possible... apologies. Recording a macro will not work though as the plugin interface buttons will not register - you need to actually code the button presses. Another thing to note is options that automatically set other options may not work. For example, using
[ISet,ZPlugin:3D Print Exporter:X,9]
does not automatically set the Y and Z values (as happens if you set it by hand).
It is also possible to run more than one zscript in the manner I suggested. If you start off the zscript with [IPress,HIDE] then focus should return to your application and subsequent calls work as intended.