ZBrushCentral

How to start writing a plugin for ZBrush (e.g. in C++)?

Hi everyone,

I was wondering how to start when I want to write a plugin for C++. I can’t find any documentation, except for the ZScript language.

But when you want to write something like the Decimation Master plugin, where do I start?

And maybe, does someone have an example script project setup to share? That would help a quick start.

Thanks!
Fernando

http://www.zbrushcentral.com/showthread.php?191848-ZFileUtils-updated-for-4R7
http://www.zbrushcentral.com/showthread.php?193080-Writing-Dll-files-for-Zbrush
I did a bunch of stuff for the UI. But not in C++. All just text files. Link to thread full below. Enjoy.

Thank you Doug, that is a great start.

One thing I would like to do is bypass certain ZBrush messages that stop an ZScript.

For example when you click ‘merge down’ in the Sub Tool, a message will appear that can only be bypassed manually.

Do you think I can program around such a message using a C++ plugin?

Rather not venture a guess, that’s what it would be. :wink:
You have found the Command Reference more than likely. http://docs.pixologic.com/user-guide/customizing-zbrush/zscripting/command-reference/#Index
You can also Export the Commands from within ZBrush(some of the online docs are not up to date yet :wink: )

I don’t think you can bypass those messages with a dll … I guess you could make a plugin that exports the subtools as obj for example, merge them and reimport them but that would be slow and not really efficient … And all that just to save you one click …
For the merge down message , The user might have to press “always yes” only once, one time in the whole zb session and that would be it…

If you are creating a user zplugin then, as Dargelos mentioned, it would be best to require the user to press “always yes”. There is no reliable solution to using an external library to dismiss the note window based messages ZBrush displays, AFAIK.

However, if you are creating a zplugin as part of an automation process that runs on a headless machine (i.e no user interaction at all), you might be able to duct tape a solution together.

The solution requires that you can reliably determine where the zbrush message appears when Merge Down is pressed. If you can determine that then you can deduct where the OK button is located on the screen. Then you would create a dll that calls a function simulating a mouse click, at a specific position (the OK button) after a short time interval. The interval is required as we want the the external library to return control to zbrush so that our zplugin can press the Merge Down button.

That should do it, in theory. The problem lies in the varying positions of the Merge Down message which can only reliably be determined when there is no user interaction at all.

Mmmm, duct tape. LOL Not the strongest though. :wink:

Thank you all for the feedback, that makes it really clear.

I also read somewhere that you can’t change processes as expected, only extend them.

It’s as though Pixologic wouldn’t want anyone to perfectly fit ZBrush into their pipeline.

Today all large and small 3D packages have an SDK or API of some sort.

I really don’t understand why Pixologic doesn’t add this to their product, since ZBrush is the standard in so many ways and so many companies rely on it. ZScripting is very rich, but also limited in some ways.

By the way, has anyone succesfully connected to a MySQL database from within ZBrush?

Zscripting’s foundation is pretty old now but it does allow you to accomplish most things, even if they sometimes must be done in roundabout ways.

Although I have grown fond of the zscripting idiosyncrasies and enjoy writing scripts, much in the same way some people enjoy putting on full body latex suits and whipping each other, I would welcome a change. All that latex gives me a rash :wink: An SDK would be nice but a slightly lower level scripting API would be just as good.

Just a thought on the note interface that the merge down button seems to use. If Pixologic could rearrange the OK and Cancel button, not in the note interface but in code, we could solve this particular problem in a reliable fashion. The first [NoteButton,…] you add to a note interface is the one you can trigger by pressing the spacebar or the return key. Then you would simply write [IKeyPress, 13, [IPress, “Tool:Sub Tool:MergeDown”]] where 13 is the ascii value for the return key. Right now we are triggering the Cancel button.

In regards to connecting to a MySQL database I have not tried it but cannot see a reason why it would not work. Just keep in mind that you would need to write an external library to connect and any communication with ZBrush would be through a memory block your zscript supplies.

Hi Mark,

Thank you for your thoughts, I agree. I’ll contact Pixologic and discuss with them other options, the default button arrangement so we could press them with a ZScript.

I hope to hear that they have planned some kind of SDK/API solution…

I’ve been trying to export displacement and normal maps on a render farm, but the Note Interface dialogs that appear when splitting polygroups is a huge blocker. Because we have no way to programmatically control the Note Interface when they pop up, I found it impossible to automate anything on the farm.
We’re dropping support for ZBrush in our pipeline because of this – our attempts have been fruitless.

@ZBrush: PLEASE FIX THIS MAJOR FLAW.

Thanks,
-dv

You’re not the first to ask for this - hopefully in 4R8.

Thank you very much! I’m learning this stuff, and I need this stuff.

I’m waiting for a SDK/API solution for 14 years and was hoping the 2018 update would bring this.
We are moving fast to procedural geometry, animations, texturing etc and I fear Pixologic doesn’t understand, what a big impact this feature could have for ZBrush.

I’m a developer specialized in procedural generation and hereby like to OFFER MY SUPPORT to build a user-friendly layer using C++ or Python which can model meshes without GUI interaction.

Have a look at Blender Python, any WebGL sandbox/playground (eg babylon.js, shadertoy) to see how fun it is to automate complexity with a few lines of code and see the results immediately.

I’m bumping this to see if there are any news about modern scripting in ZBrush with a real programming language like python.
Are there any rumours?