ZBrushCentral

Back from the Ashes - The Intuos Plugin Dream lives again

It is alive!!!

After a little more than one year, I am back trying to write an external app in order to tighten the integration between ZB and my Intuos tablet.

Shortly after my last post, I almost gave up due to the apparent impossibility to capture tablet data from another app. But after quite a strugle, I managed to overcome this obstacle.

Not only that, but now I have managed to extract all the information I need (wheel position, stylus id, etc) from the driver.

All I need to do now is find a way to send these to ZB. And to do this, I need help with a few ‘basic’ doubts about ZScript:

1- How can I get/set the current brush through ZScript?
2- Can I set brush settings (like zIntensity, radius, etc) directly through ZScript?
3- Can I call functions from an app/dll implemented in C# from ZScript?
4- Can a ZScript run in an infinite loop for as long as it is active without freezing the app?
5- Can an external app cause ZB to run a specific script without sending keyboard messages?

My first idea was to study the ZScript ref, but I can’t seem to find it online. The link at the top of this forum is dead.

Thanks in advance

Sygnus

Decided to record some basic actions on ZB and inspect the generated scripts and found answers to most of my questions.

There are still some bits that I can’t get from recorded sessions and still require help, though.

1- How can I get/set the current brush through ZScript?
:bulb: Found how to set the current brush (using IPress)
:angry: Still have to find out how to GET the current brush
2- Can I set brush settings (like zIntensity, radius, etc) directly through ZScript?
:bulb: Covered: [ISet,Draw:Draw Size,X], [ISet,Draw:Focal Shift, X], etc
3- Can I call functions from an app/dll implemented in C# from ZScript?
:bulb: Got it too: FileExecute.
4- Can a ZScript run in an infinite loop for as long as it is active without freezing the app?
:roll_eyes: I guess Sleep/Sleepagain would be just the thing… if only they would take fractions of a second… will have to think a little more about this one.
5- Can an external app cause ZB to run a specific script without sending keyboard messages?
:angry:small_orange_diamond:angry: The biggest chalange so far. Really need help whith this one! Please!

By the way, found the links to the ZScript Ref:
http://www.pixologic.com/docs/index.php/ZScript_Basics
http://www.pixologic.com/docs/index.php/ZScript_Command_Reference

  1. You can find out the current brush either by using:

[IGetTitle,Brush:Current Brush,1]

or from the ‘Item Info’ slider (the slider at the top of the palette):

[IGetTitle,Brush:Item Info,0]

Note that the return value varies for these two and you’ll need to be careful how you use them. For example, the Item Info slider returns the name of the brush with a period (.) on the end. You’ll probably need to trim this off using [StrExtract].

The Item Info slider is useful for getting/setting the brush as you can use the numerical values -

[VarSet,brushID,[IGet,Brush:Item Info]]
//do stuff
[ISet,Brush:Item Info, #brushID]

However note that if you want to get/set masking or selection brushes you will need to simulate the Ctrl/Shift keypresses using [IKeyPress]. And don’t forget that the brushes that are available will vary depending on what type of tool is selected (they’re different for ZSketch).

  1. You can use [Sleep] with fractions of a second. However it is only active while the zscript is active. The active zscript is replaced as soon as the user loads a different plugin/zscript (for example, by using the [ ] to change brush size).

  2. You can use ShellExecute in a separate app to get ZBrush to load a zscript (a ZSC file). You need to pass in the full path to the ZBrush executable and the zscript file.

HTH,

Dear Marcus,

[IGetTitle,Brush:Current Brush,1]

is exactly what I was looking for! Thank you!

I’m not sure yet whether ZB will talk directly to my app or send messages via micro files, but either way, with the name of the brush I can use IPress to select a brush when I need it.

About ShellExecute,
could you give me an example (in C++ or any other language)?

Also, I have one more question: is there a way to create shortcuts composed of multiple keys, like the ones on the brush selection? Say, ctrl+alt+88 to set zIntensity to 88%, or something similar? And how can I use ISetHotKey to assign hotkeys for special keys like F1-F12, Alt+something, etc?

Thanks again

Sygnus

  1. C++ ShellExecute example attached. Note that if you place the ZSC file inside the Pixologic folder (or a subfolder of this) then ZBrush will expect to find it in the default ZScripts folder and you’ll get an error. Likewise, if you only specify a file name ZBrush will look in the ZScripts folder for the ZSC.

  2. You can specify key combinations such as Ctrl+‘k’ for hotkeys using the ASCII values (so Ctrl+‘k’ would be 512 + 107 or 619). You can get these values by saving out a hotkey and examining the StartupHotkeys.txt file in the ZStartup/Hotkeys folder.

You can’t use a hotkey to automatically set a value. You’d have to create a plugin button that set the specific amount and use the hotkey on that.

HTH,

@marcus_civis

I can’t seem to set the smooth and masking brushes to a variable using the method you mentioned. The values for “var2” and “var3” just return the regular brush item info rather than the selected smoothing or masking brushes. Do I have the IKeyPress in the wrong location?

[IButton,brushSettings,“brush settings”,
[VarSet,var1,[IGet,Brush:ItemInfo]]
[IKeyPress,CTRL,[VarSet,var2,[IGet,Brush:ItemInfo]]]
[IKeyPress,SHIFT,[VarSet,var3,[IGet,Brush:ItemInfo]]]
//space for actions that mess with other brushes
[ISet,Brush:ItemInfo,var1]
[IKeyPress,‘1’,[ISet,Brush:ItemInfo,var2]]
[IKeyPress,‘1’,[ISet,Brush:ItemInfo,var3]]
[Note,[StrMerge,var1,"\n",var2,"\n",var3]]
,0,0.5]

Thanks