ZBrushCentral

Brush WrapMode button toggle

I don’t think that the fact to be able to hold any modifier key while running the script would matter (does it?).

It matters in that ZBrush will tell you (possibly for each masking/smoothing brush) “This brush will be selected as the active ‘masking’ brush.” and then ask you to press OK or skip this note until next restart.

Not a big problem, just an inconvenience. With some earlier code it did fail for me, were holding SHIFT would select the main brush, i.e no change.

That said, many thanks again for taking the time to solve this issue for me !

You are welcome, just be ready for the ZScript quiz that I am going to send you later :wink:

the active ‘masking’ brush." and then ask you to press OK or skip this note until next restart.

Not a big problem, just an inconvenience. With some earlier code it did fail for me, were holding SHIFT would select the main brush, i.e no change.

Ahhhh understood: now I know which message you’re talking about. “THE” silly message that I use to dismiss until the end of the session every time (I would really like that Pixologic would give us the opportunity to turn off that message. :lol:

ZBrush_Silly_Warning.jpg

Btw not a big deal: after dismissing the first warning (until the end of the session) the rest should be fine. :wink:

Hey Mark,

this morning I hard coded the brushes in your code and they all work great (including Smooth and Masking brushes).
Also no Warning is displayed for Smooth and Masking brushes when running the script (the thing you were worried about).
So at the end of the day you created a great script ! Many thanks again. :smiley:

Here follows the script code I created (with my ownd harcoded brushes) using your code: maybe someone else may find it useful. :slight_smile:
Apologies for the flat highlighting but I cannot get a decent colorcoding in Notepad++. :frowning:
I also attached the .txt file so to preserve the correct code indentation (as you did before).

[IConfig,4.73]

[ISubPalette, “Zplugin:Brush WrapMode”]

[VarSet, brushCount, 34]
// brushes() defines the pathname and brushType() defines what type of brush it is.
// 0: standard modeling brush.
// 1: smooth brush.
// 2: masking brush.
[VarDef, brushes(brushCount), “”] [VarDef, brushType(brushCount), 0]
[VarSet, brushes(0), “Brush:Morph”] [VarSet, brushType(0), 0]
[VarSet, brushes(1), “Brush:Standard”] [VarSet, brushType(1), 0]
[VarSet, brushes(2), “Brush:Dam_Standard”] [VarSet, brushType(2), 0]
[VarSet, brushes(3), “Brush:hPolish”] [VarSet, brushType(3), 0]
[VarSet, brushes(4), “Brush:Flatten”] [VarSet, brushType(4), 0]
[VarSet, brushes(5), “Brush:Planar”] [VarSet, brushType(5), 0]
[VarSet, brushes(6), “Brush:TrimDynamic”] [VarSet, brushType(6), 0]
[VarSet, brushes(7), “Brush:TrimAdaptive”] [VarSet, brushType(7), 0]
[VarSet, brushes(8), “Brush:TrimSmoothBorder”] [VarSet, brushType(8), 0]
[VarSet, brushes(9), “Brush:MalletFast”] [VarSet, brushType(9), 0]
[VarSet, brushes(10), “Brush:MalletFast2”] [VarSet, brushType(10), 0]
[VarSet, brushes(11), “Brush:Move”] [VarSet, brushType(11), 0]
[VarSet, brushes(12), “Brush:Move Elastic”] [VarSet, brushType(12), 0]
[VarSet, brushes(13), “Brush:Alpha”] [VarSet, brushType(13), 0]
[VarSet, brushes(14), “Brush:Clay”] [VarSet, brushType(14), 0]
[VarSet, brushes(15), “Brush:ClayBuildup”] [VarSet, brushType(15), 0]
[VarSet, brushes(16), “Brush:ClayTubes”] [VarSet, brushType(16), 0]
[VarSet, brushes(17), “Brush:ClayPolish”] [VarSet, brushType(17), 0]
[VarSet, brushes(18), “Brush:ajClay”] [VarSet, brushType(18), 0]
[VarSet, brushes(19), “Brush:ajPolish”] [VarSet, brushType(19 ), 0]
[VarSet, brushes(20), “Brush:ajNoise”] [VarSet, brushType(20), 0]
[VarSet, brushes(21), “Brush:Orb.Cracks”] [VarSet, brushType(21), 0]
[VarSet, brushes(22), “Brush:ajCracks”] [VarSet, brushType(22), 0]
[VarSet, brushes(23), “Brush:ajPinch”] [VarSet, brushType(23), 0]
[VarSet, brushes(24), “Brush:Pinch”] [VarSet, brushType(24), 0]
[VarSet, brushes(25), “Brush:Inflat”] [VarSet, brushType(25), 0]
[VarSet, brushes(26), “Brush:Magnify”] [VarSet, brushType(26), 0]
[VarSet, brushes(27), “Brush:CurveTubeSnap”] [VarSet, brushType(27), 0]
[VarSet, brushes(28), “Brush:CurveLineTube”] [VarSet, brushType(28), 0]
[VarSet, brushes(29), “Brush:Smooth”] [VarSet, brushType(29), 1]
[VarSet, brushes(30), “Brush:SmoothValleys”] [VarSet, brushType(30), 1]
[VarSet, brushes(31), “Brush:SmoothPeaks”] [VarSet, brushType(31), 1]
[VarSet, brushes(32), “Brush:MaskPen”] [VarSet, brushType(32), 2]
[VarSet, brushes(33), “Brush:LazyMask”] [VarSet, brushType(33), 2]

[IButton, “ZPlugin:brush WrapMode:WrapMode Main Brushes”, “Toggle WrapMode of the Main Brushes between 0 an 1.”,
[IFreeze, // Stops interface updates while we switch brushes.
// Store the currently selected modeling brush.
[VarSet, currentBrush, [IGet, 30516]] // 30516 is the Brush slider.
// Determine the new WrapMode
[If, [IGet, “Brush:Curve:WrapMode”], // WrapMode is 1 or higher.
[VarSet, newWrapMode, 0]
,
[VarSet, newWrapMode, 1]
]
// Set the new WrapMode for the currently selected brush.
[ISet, “Brush:Curve:WrapMode”, newWrapMode]
// Store the currently selected smooth brush.
[IKeyPress, SHIFT,
[Delay, 0.05] // Apparently needed to read the brushName.
[VarSet, brushName, [IGetTitle, 30516]]
[VarSet, smoothPath, [StrMerge, “Brush:”, brushName]]
// Remove the . and space from the path.
[VarSet, smoothPath, [StrExtract, smoothPath, 0, [StrLength, smoothPath] - 2]]
[ISet, “Brush:Curve:WrapMode”, newWrapMode]
]
// Store the currenlty selected masking brush.
[IKeyPress, CTRL,
[Delay, 0.05] // Apparently needed to read the brushName.
[VarSet, brushName, [IGetTitle, 30516]]
[VarSet, maskPath, [StrMerge, “Brush:”, brushName]]
// Remove the . and space from the path.
[VarSet, maskPath, [StrExtract, maskPath, 0, [StrLength, maskPath] - 2]]
[ISet, “Brush:Curve:WrapMode”, newWrapMode]
]
// Then set WrapMode for the hardcoded brushes.
[Loop, brushCount,
// Checks if the interface path name or UI ID exists.
[If, [IExists, brushes(index)],
[If, brushType(index) == 0,
[IPress, brushes(index)]
[ISet, “Brush:Curve:WrapMode”, newWrapMode]
[LoopContinue] // No need to check for other brushType().
]
[If, brushType(index) == 1,
[IKeyPress, SHIFT,
[IPress, brushes(index)]
[ISet, “Brush:Curve:WrapMode”, newWrapMode]
]
[LoopContinue] // No need to check for other brushType().
]
[If, brushType(index) == 2,
[IKeyPress, CTRL,
[IPress, brushes(index)]
[ISet, “Brush:Curve:WrapMode”, newWrapMode]
]
]
]
, index]
// Restore the previously selected smooth, mask and modeling brushes.
[IKeyPress, SHIFT,
[IPress, smoothPath]
]
[IKeyPress, CTRL,
[IPress, maskPath]
]
[ISet, 30516, currentBrush]
] // End of IFreeze
, /DISABLED ?/, /BUTTON WIDTH/, , /BUTTON ICON/, /BUTTON HEIGHT/]

That’s great! Glad you are happy with it.

The ZBrush warning message is only displayed if you hold SHIFT or CTRL when you press your WrapMode Main Brushes button.

In order to get syntax highlighting (colorcoding) you will first need to copy your code and paste it into the ZBC Syntax Highlighter.

In order to get syntax highlighting (colorcoding) you will first need to copy your code and paste it into the ZBC Syntax Highlighter.

Oh, right ! I didn’t thought about that ! :idea:

Thanks for the tip. :smiley:

You are welcome, just be ready for the ZScript quiz that I am going to send you later :smiley:

Oh btw I missed this one before: which quiz? :smiley: