Hi,
ZBrush 4R8 has some UI changes which affect how zscripts run, so some plugins and macros will need updating before they will work as expected in the new version. The changes primarily affect those scripts which deal with subtool visibility.
Another change which wonât affect older scripts but will be a useful enhancement to zscript is the ability to dispel the warning message that pops up for âun-doableâ actions, such as deleting a subtool.
Example is code below. The attached file is the same code so you can load directly in 4R8 for testing.
Any problems or questions, let me know.
//ZScript changes for 4R8
[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
[RoutineDef,DoIt,//start of routine
//put code here for whatever you want to do
[Note,âTESTâ] //this note just to show - remove
]//end of routine
[IButton,âGet All Visâ,âCheck Visibility of All subtoolsâ,
[RoutineCall,CheckVersion]
[RoutineCall,CheckSubTool]
[VarSet,activST,[SubToolGetActiveIndex]]//store active subtool
[Loop,[SubToolGetCount],//loop through all subtools
[SubToolSelect,[Val,n]]
//check visibility
[If,([IModGet,âTool:Subtool 0â]&32 == 32),
//code for visible subtool
[Note,[StrMerge,âSubTool #â,[Val,n]," is VISIBLE"],1]
,
//code for invisible subtool
[Note,[StrMerge,âSubTool #â,[Val,n]," is HIDDEN"],1]
]
,n]//end loop
[SubToolSelect,activST]//reselect active subtool
]//end button
[IButton,âDo Visibleâ,âRun routine on Visible subtoolsâ,
[RoutineCall,CheckVersion]
[RoutineCall,CheckSubTool]
[VarSet,activST,[SubToolGetActiveIndex]]//store active subtool
[Loop,[SubToolGetCount],//loop through all subtools
[SubToolSelect,[Val,n]]
//check visibility
[If,([IModGet,âTool:Subtool 0â]&32 == 32),
//code for visible subtool
[RoutineCall,DoIt]
]
,n]//end loop
[SubToolSelect,activST]//reselect active subtool
]//end button
[IButton,âGet Selected Visâ,âCheck Visibility of Selected subtoolâ,
[RoutineCall,CheckVersion]
[RoutineCall,CheckSubTool]
[VarSet,activST,[SubToolGetActiveIndex]]
[ISet,Tool:Sub Tool:SubTool ScrollBar,0,([SubToolGetCount]-(activST+1))]
[If,([IModGet,âTool:Subtool 0â]&32 == 32),
[Note,âSelected subtool is VISIBLEâ,1]
,
[Note,âSelected subtool is HIDDENâ,1]
]
]//end button
[IButton,âGet Selected SubTool All Modsâ,âCheck Icon status of Selected subtoolâ,
[RoutineCall,CheckVersion]
[RoutineCall,CheckSubTool]
[VarSet,activST,[SubToolGetActiveIndex]]
//positions scrollbar so subtool at top of list
[ISet,Tool:Sub Tool:SubTool ScrollBar,0,([SubToolGetCount]-(activST+1))]
//check the mods
[If,([IModGet,âTool:Subtool 0â]&32 == 32),
[Note,"Is visible
",-1]
]
[If,([IModGet,âTool:Subtool 0â]&16 == 16),
[Note,"Polypaint on
",-1]
]
[If,([IModGet,âTool:Subtool 0â]&1 == 1),
[Note,"START
",-1]
]
[If,([IModGet,âTool:Subtool 0â]&2 == 2),
[Note,"Addition
",-1]
]
[If,([IModGet,âTool:Subtool 0â]&4 == 4),
[Note,"Subtraction
",-1]
]
[If,([IModGet,âTool:Subtool 0â]&8 == 8),
[Note,"Intersection
â,-1]
]
[Note,â "]//display result
]//end button
//The âAction Is not Undoableâ warning note can now be dismissed by ZScript
//by using [IKeyPress,â1â,âŠ] to select the first option,
//[IKeyPress,â2â,âŠ] for select the 2nd option, etc.
//***Note that the â â is required.
//Example for deleting a subtool:
[IButton,âDelete Subtoolâ,âDelete selected subtool - without warning!â,
[RoutineCall,CheckVersion]
[RoutineCall,CheckSubTool]
//IKeyPress of 2 will select the second option of the dialog popup.
[IKeyPress,â2â,[IPress,Tool:SubTool: Delete]]
]//end button
Code as a txt file: 4R8 ZScript Changes.txt (3.33 KB)
Using ZScript to toggle the tray Dividers in 4R8 P2
P2 introduces a change to the way the Dividers work - you now have to double-click them to open or close the trays. Itâs not possible to assign a hotkey to Divider directly but it is possible with a macro. Two [IClick]s are used to simulate a double-click on the divider.
Hereâs the code for the left tray:
[IButton,???,âToggle left trayâ,
[IConfig,4.8]
[IClick,1000]
[IClick,1000]
]
(The right tray is the same except for 1001 being used instead of 1000.)
This should work in most cases but if you have set the Preferences>Interface>Click Time slider to above 0.5 you will find that a single [IClick] will be sufficient.
***Please Note : ZFileUtils has been updated for ZBrush 4R8 - see separate post here.4R8 ZScript Changes.txt (3.33 KB)