ZBrushCentral

Question: Can you hide a subtool programmatically without selecting it

I have been able to write code that turns on/off the visibility of a specific sub tool.

I first recorded a new macro where I just deselected a tool. I looked at the generated code and saw that it used the IModSet command with 1 as a value.

I used that code in my own plugin script and I am able to turn off the visibility but if the subtool that I want to hide isn’t selected it first gets selected…and the second time I run my script it turns of the visibility. When I click the visibility icon with the mouse it doesn’t select the subtool but when you do IModSet it seems to first select the subtool.

Anyone know if there is a different way to hide a subtool without having to select it first?

Running zBrush 4 on latest Mac OS.

Thanks,

mobbe

However, if you for instance have two subtools and tool #1 is selected and you want to hide #2 th

With a bit of care you can imitate the mouse-clicking behaviour in zscript and avoid selecting the subtool. You need to make sure that you get the right place to click, so allowance has to be made for people’s button width preference. Using [IWidth] solves this.

The correct subtool can be selected by positioning the scroll bar. It can be set so that any subtool is in the ‘0’ position at the top of the list. Its secondary value gives this, with the top subtool being one less than the total subtools and the bottom subtool zero.

Here’s the code:


[IButton,Toggle,"Toggle subtool visibility",
	[VarSet,subT,1]// the subtool you want to turn on/off - 1 is the top subtool
	[IFreeze,
		[VarSet,tmpScr,[IGetSecondary,Tool:Sub Tool:SubTool ScrollBar]]//get scroll bar position
		[VarSet,totalST,[StrExtract,[IGetTitle,Preferences:Misc:SubTools Count],10,256]]//get total subtools
		[VarSet,btnWidth,[IWidth,Tool:Sub Tool 0]-10]//get the width of the button less 10 pixels		
		[ISet,Tool:Sub Tool:SubTool ScrollBar,0,(totalST-subT)]//set the scroll bar so the subtool is '0'		
		[IClick,Tool:Sub Tool 0,btnWidth,5]//click the subtool 'eye'
		[ISet,Tool:Sub Tool:SubTool ScrollBar,0,tmpScr]//reset scroll bar
	]
]

Note that if the subtool you’re toggling is the selected one you will turn on/off all subtools.

HTH,

That worked great! Thanks for the code snippet.

Regards,

mobbe