ZBrushCentral

Tricky script : Need help

Hi there my dear scripting fellows. I wonder if anyone can help me with the following:
I want to switch down the Transform brushes (Standard–>StdDot–>Inflat–>…) when pressing only one single hotkey and the selection should return to the first brush when the last one came.

I hope you understand me. Sorry but describing such things ain’t so easy for a german guy…

Peace-out folks

This isn’t difficult if you use the numerical window IDs which you can find by looking at the Preferences>Utilities>View Window ID slider while mousing over the button. To find what state a button is in you can use the IGetFlags command, testing to see what flag is returned for what state. Then it is a simple matter of setting up a loop to find the button that is on, switch that off and the next on, with an If statement to return the cycle to Std:


[IButton,"Brush","Set Edit brush mode",
	[If,[IGetFlags,Transform:Edit]=9,//checks that in Edit mode
		
		[Loop,8,//loop to find current mode
	    [If,[IGetFlags,[Val,n+1072]]=9,[LoopExit]]
	 	,n]
	 	
	 	[If,[Val,n+1072]=1079,[ISet,1079,0][ISet,1072,1]//set Std ON if Nudge
	 	,//else
	 	[ISet,[Val,n+1072],0][ISet,[Val,n+1073],1]//set next ON
	 	]//end if
	 		 	
	,//else
	 	[Note,"No 3D object in Edit mode."]
	]//end if
	
,,,'1']//hotkey


You’ll note that the layout of the buttons is not quite in numerical order so the cycle is not quite as you’d expect, and I’ve ignored the Morph and Morph Dot buttons which would need extra coding as you have to have a Morph Target stored before they become available.

Thanks a lot for reply. Ill give it a try

Are window ID’s constant on all machines, and OS’s, And ZBrush Versions?
If so, that is great to know.

Chris,

The window IDs are constant for all permanent ZBrush interface items for a particular version and [IConfig should take care of any version differences. But user-added plugin items will change depending on what the user has installed so you need to use something along the lines of:


[If, [Iget, Preferences:Utilities:View Window ID] = [IgetID, "ZPlugin:MyPlugs:MyButton"],

H3y marcus, a little supplementary question: What if I just want to switch through “Standard-Inflat-Smooth” and skip the other brushes ?

P.S. Thanx again mate your script worked nicely you really got ahead of yourself with the previous one…

You’d simply use:

[IButton,"Brush","Set Edit brush mode",
	[If,[IGetFlags,Transform:Edit]=9,//checks that in Edit mode
		
		[Loop,8,//loop to find current mode
	    [If,[IGetFlags,[Val,n+1072]]=9,[LoopExit]]
	 	,n]
	 	
	 	[If,[Val,n+1072]=1072,[ISet,1072,0][ISet,1074,1]]
	 	[If,[Val,n+1072]=1074,[ISet,1074,0][ISet,1077,1]]
	 	[If,[Val,n+1072]=1077,[ISet,1077,0][ISet,1072,1]]
	 	
	 		 	
	,//else
	 	[Note,"No 3D object in Edit mode."]
	]//end if
	
,,,'1']//hotkey

But the Smooth brush is available by default if you hold down Shift. (You can change this to another option - such as Inflat - by holding down Shift while clicking one of the [Inflat] button.)

Phew your a quick little devil g Yes you’re right. Normally you wouldn’t bind Smooth to another key than shift. But sometimes it can be annoying holding down shift all the time.

BTW: Is there a way to change pre-defined keybindings like SPACEBAR ? I would like to bind it to another script. I normally don’t use the Quickmenu which appears when holding down SPACE.

Maybe you wanna have a look at my works here :
Human anatomy study

Yes, you can do that. Hotkeys that are assigned to buttons for a zscript will replace any ZBrush hotkeys while that zscript is loaded. To change the hotkey for any of the permanent ZB interface items you need to edit the defaultzscript. If you search here at ZBC you’ll find several posts on doing that.

Using the Spacebar is slightly problematic but can be done. In the code below you’ll see I use the [CanvasClick,…] command with a click off the canvas. This is to dismiss the QuickMenu which would otherwise show. I’ve also added an indicator in the NoteBar to show which brush mode you’re in - thought it might be useful. You’ll notice that you can use the Right Mouse Button to change your brush mode as well as the Spacebar.

Although I don’t see any reason why there should be problems with this method, use at your own risk!

Good work on the anatomy study!