1. Home
  2. Docs
  3. Zbrush
  4. Zscripts
  5. ZScript Code Samples

ZScript Code Samples

Check in a loop which subtools are visible or not.

This code sample is checking all the Subtools hosted within the current Ztool, and report into a Note , which subtools are visible and report into another Note if the active subtool isn’t visible.

ZBRUSH 4R8

[VarDef,subtoolName,""] // Define a new variable to store the current subtool name 
[VarDef,subtool(1024),0] // Define a Variable list to store the subtool active index
[VarSet,totalSubtools,[SubToolGetCount]] // create a variable to define the number of loop based on the subtools count
[VarSet,activeSubtool,[SubToolGetActiveIndex]] // create a variable with the current subtool Index

// Select the first subtool of the Ztool
[If, activeSubtool==0,
    [SubToolSelect,1]
]
// here is the Loop that check each subtool, and check if the subtool is visible or not.
[Loop, totalSubtools,
    [SubToolSelect,[Val,n]]
    [VarSet,subtoolName,[IGetTitle, "Tool:ItemInfo"]]//gets the tool name
    [VarSet,subtoolName,[StrExtract,subtoolName,0,[StrLength,subtoolName]-2]]// trim 2 chars from the end

    // here we check if the activeSubtool is visible ( return 1 if visible and 0 if not )

    [If,([IModGet,"Tool:Subtool 0"]&32 == 32),

       [Note, [StrMerge, subtoolName, " is VISIBLE"],,2]
       ,//else
       [Note, [StrMerge, subtoolName, " is NOT VISIBLE"],,2]
    ]

,n] //END LOOP

 

ZBRUSH 4R7 (and previous version)

[VarDef,subtoolName,""] // Define a new variable to store the current subtool name 
[VarDef,subtool(1024),0] // Define a Variable list to store the subtool active index
[VarSet,totalSubtools,[SubToolGetCount]] // create a variable to define the number of loop based on the subtools count
[VarSet,activeSubtool,[SubToolGetActiveIndex]] // create a variable with the current subtool Index

// Select the first subtool of the Ztool
[If, activeSubtool==0,
    [SubToolSelect,1]
]
// here is the Loop that check each subtool, and check if the subtool is visible or not.
[Loop, totalSubtools,
    [SubToolSelect,[Val,n]]
    [VarSet,subtoolName,[IGetTitle, "Tool:ItemInfo"]]//gets the tool name
    [VarSet,subtoolName,[StrExtract,subtoolName,0,[StrLength,subtoolName]-2]]// trim 2 chars from the end

    // here we check if the activeSubtool is visible ( return 1 if visible and 0 if not )

    [If,[IModGet,[StrMerge,"Tool:Sub Tool:",#subtoolName]=]=>=16
        ,//cmds
        [Note, [StrMerge, subtoolName, " is VISIBLE"],,2]
        ,//else
        [Note, [StrMerge, subtoolName, " is NOT VISIBLE"],,2]
    ]

,n] //END LOOP

 

 

How can we help?