Since I spend most of my time in Zbrush I started eliminating parts of the workflow that annoys me. I really don't like hiding specific subtools since it requires looking into subtools palette. I tried to find a Zscript that could hid subtool under mouse cursor. I found this thread:
http://www.zbrushcentral.com/showthread.php?162766-Hide-subtool-under-mouse Below you can find a code those guys wrote. It's slightly modified by me. I commented out the lines that toggle 'Auto Select Subtool' option. You don't need it if you have it turned on by default. The problem is that this script works once! After you trigger it through hotkey you have to change the hotkey to be able to trigger it again... I don't have experience in Zbrush scripting. Even though I tried to decode this code I can't figure out why the hot key stops working. Also sometimes it hides more than the subtool the mouse pointer hovers above. I also need a script that unhides all of the hidden subtools.
Any help would be appreciated.
[IButton,Toggle,"Toggle subtool visibility",
[IConfig,4.6]
//store the scrollbar position
[VarSet,tmpScrollPos,[IGetSecondary,Tool:Sub Tool:SubTool ScrollBar]]
//find the selected subtool
[VarSet,totalSubTools,[StrExtract,[IGetTitle,Preferences:Misc:SubTools Count],10,256]]
[If,totalSubTools>8,
[VarSet,i,1]
[VarSet,subToolPath,"Tool:Sub Tool:SubTool 0"]
[Loop,totalSubTools,
[VarSet,scrollPos,(totalSubTools-i)]
[ISet,Tool:Sub Tool:SubTool ScrollBar,0,scrollPos]
[If,[IGetFlags,#subToolPath]>=9,
[VarSet,activeSubT,[IGetTitle, Tool:Current Tool]]
[LoopExit]
]
[VarInc,i]
]
,
[VarSet,scrollPos,tmpScrollPos]
[Loop,totalSubTools,
[VarSet,subToolPath,[StrMerge,"Tool:Sub Tool:SubTool ",[Val,n]]]
[If,[IGetFlags,#subToolPath]>=9,
[VarSet,activeSubT,[IGetTitle, Tool:Current Tool]]
[LoopExit]
]
,n]
]
//do select. . . ( marcus civis )
//[IPress,Preferences:Edit:Auto Select SubTool]
[IKeyPress,1064,[CanvasClick,[MouseHPos],[MouseVPos]]]
//[IUnPress,Preferences:Edit:Auto Select SubTool]
//
//and then set var1 to that selection
[VarSet,hideSubT,[IGetTitle, Tool:Current Tool]]
//hide var1
[If,([StrLength,hideSubT]==[StrLength,activeSubT])&&([StrFind,hideSubT,activeSubT]>-1),
//active subtool - do nothing
,//if it's not the active subtool
[IModSet,[StrMerge,"Tool:SubTool:",hideSubT],1]
]
//switch back to selected subtool
//set the scrollbar so subtool shows
[ISet,Tool:Sub Tool:SubTool ScrollBar,0,scrollPos]
//select subtool
[IPress,#subToolPath]
//reset scrollbar
[ISet,Tool:Sub Tool:SubTool ScrollBar,0,tmpScrollPos]
]
Replies
Hiding more than one subtool I think is an issue with the accuracy of the CanvasClick command. I'm not sure if there is anything that can be done about it. This Macro is pretty old now I will think if there is a better way to do it but I doubt it.
The one time triggering is described in Zbrush scripting docs. It's intentional (if you are loading script through z scripting palette). I compiled it into a button and threw it into ZStartup folder and now it works ok. Here is the code (unhiding doesn't work for now):
Zscript syntax blows... at least for some one who codes in C/C++ and Python...
I abandoned this idea because I really can't learn Zscripting properly right now. To may things on my plate. Also my script sometimes doesn't work at all. Sometimes it does but not properly. It's just too unreliable and I lack the skills to make it better. I posted the code so if anyone who wants to improve it could.
Right now I don't think I can add anything constructive to this script. Also what I wrote is a hack with parts of someone else's code.
You can find the keypress ID of the pressed key in Preferences>Utilities> Value of 2nd Slider
http://www.zbrushcentral.com/showthread.php?162766-Hide-subtool-under-mouse&p=1213745&viewfull=1#post1213745
// Written by MrOneTwo - Michal Ciesielski
[RoutineDef,CheckVersion,//check that version is 4R8
[If,([ZBrushInfo,0]< 4.8),
[Note,"This script is not for this version of ZBrush"]
[Exit]
]
]//end of routine
[RoutineDef,CheckSubTool,//check that we have a subtool
[If,[IExists,Tool:SubTool:Select Down],
//do nothing - all OK
,//else not a subtool
[Exit]
]
]//end of routine
[IButton, ???,"Hide subtool under the cursor",
[RoutineCall,CheckVersion]
[RoutineCall,CheckSubTool]
[VarSet,activST,[SubToolGetActiveIndex]]
[IKeyPress, ALT, [CanvasClick,[MouseHPos],[MouseVPos]]]
[VarSet,hidingST,[SubToolGetActiveIndex]]
[ISet,Tool:Sub Tool:SubTool ScrollBar,0,([SubToolGetCount]-(hidingST+1))]
[If,([IModGet,"Tool:Subtool 0"]&32 == 32),
[Note,"Is visible\n",,-1]
[IModSet, "Tool:Subtool 0", 18]
]
//positions scrollbar so subtool at top of list
[ISet,Tool:Sub Tool:SubTool ScrollBar,0,([SubToolGetCount]-(activST+1))]
[SubToolSelect, activST]
]//end button
https://youtu.be/pVVLO7PG7aQ