ZBrushCentral

ZBrush 4R8 - changes affecting ZScript - P2 included

Hi, :slight_smile:

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)

Thanks for this Marcus, huge help!

Has anything changed with the way ISwitch commands work in regards to toggling on and off a default UI item in 4r8?

A lot of my ISwitch commands don’t work the way the used to in 4r7p3. They seem to almost be intertwined, when I press any of my ISwitch buttons, one or more get turned on simultaneously and I can’t sort it out.

Hope that makes sense, and thanks again for your time.

Hi Eric,

I’m not aware of any changes to the way ISwitches function. What you describe sounds like an issue to do with when the plugin is loaded, and the default states of the switches, but I’d need to see the complete code to be certain. Do send me a private message if you wish.

Marcus,
Your’re ahead of the game as always! Do you know of any new ZScript features or functions at all?

So far, only the modification to IKeyPress mentioned above, though I hope to add some useful stuff to the ZFileUtils in due course.

Nice to see zscript also got an update.

Hello Guys, thx Marcus for the full detail, iam sorry but i will just complain about a false Zscript improvement.
they just had fixed the issue for one type of note interface, not for every of them. ;p

  1. still impossible to set a value for *bpr filters > “filter type” & “blend mode”

  2. it’s still impossible to create a rollout menu

  3. they have reiterated for the imm viewer, thre is no button path or item id, it’s impossible to change the active immBrush when the panel is displayed on top of the ui and you enter in the transform:move mode.
    I d like to make a Imm brush to Ztool, but its impossible.

  4. [Iclose, “brush:brushname”] doesn’t work, you can’t to clean up a zproject file, only by loading a new resource on the top of the one you want to remove. I like a way to clean up Zbrush resource without to restart zbrush.

Some item id numbers have changed which WILL need editing in some macros.

Hi Marcus, any progress on 4R8 ZFileUtils?

Cheers!

Hi,

It will be released next week. It will be worth the wait. :wink: