Home Technical Talk

Zbrush Set Wrap Mode Globally?

greentooth
Offline / Send Message
CheeseOnToast greentooth
Hey all,

I'm finding myself using Zbrush more and more for the creation of tiling textures. I've yet to find a quick way to set wrap mode for all brushes at once, and have to do it for each brush individually. Anyone know a way to set a global value for this?

Replies

  • cryrid
    Offline / Send Message
    cryrid interpolator
    This wouldn't set it for all brushes at once, but it's something I use to speed up the process a bit. Just a simple script you can bind to a hotkey, which will toggle wrap mode between 0 and 1 (or whatever value you specify)
    [IButton,Wrap Mode Toggle,"Press to toggle the Wrapmode Value off and on.",
    [IConfig,4.31]
    [If, [IGet,Brush:Curve:WrapMode]=0, [ISet,Brush:Curve:WrapMode,1], [ISet,Brush:Curve:WrapMode,0]]
    
  • CheeseOnToast
    Offline / Send Message
    CheeseOnToast greentooth
    Nice one Cyrid. That'll do nicely.
  • < ASH >
    Offline / Send Message
    < ASH > polycounter lvl 13
    I was researching on this topic myself today because I wanted to do a button to toggle the WrapMode between 0 and 1 for each brush without having to use the slider (that I find really annoying).

    So after bumping into this thread I thought would be cool to have a toggle switch button, so I modified cryrid script with a little to use the ISwitch command.

    I created a simple script that add the Brush WrapMode subpallet in the Zplugin menu that contain a switch button named WrapMode: when enabled sets the WrapMode of the selected brush to 1, when disabled reset the WrapMode of the selected brush to 0.

    wwiwz7.jpg2mo47th.jpg

    That's the code:
    [ISubPalette,"Zplugin:Brush WrapMode"]
    
    [ISwitch, "Zplugin:Brush WrapMode:WrapMode",0, "Toggle the brush WrapMode between 0 and 1",
    	
    	[ISet,Brush:Curve:WrapMode,1]
    	
    	,
    	
    	[ISet,Brush:Curve:WrapMode,0]
    		
    	]
    

    At the moment unfortunately the button switch doesn't work as I would like.
    The button status (ON/OFF) doesn't update when I change brush.
    Lets say that I am using the Standard brush and I enable the WrapMode using my script (the button turns ON), then I change brush, but the button remains ON (instead should turn OFF because that other brush has WrapMode set to = at the moment).
    The problem is that I cannot figure out a way to update the button switch status according to each brush I select.
    It should be matter, each time I select a new brush, to read the WrapMode value of each brush and then update the WrapMode status button accordingly.

    After checking the Pixologic documentation about the ISwitch command I tried many different scripts but I cannot figure out a solution that solves the bug described above.

    Anybody can help me please? :poly122:
  • < ASH >
    Offline / Send Message
    < ASH > polycounter lvl 13
    Well apparently there's no solution to the bug I described above.
    I asked on the Zscript Pixologic Forum and I have been told that this is one of the limit of the current Zscripting. :(

    So the only doable solution is to make a simple button and place it in the interface near the WrapMode slider to be able to tell if is set to 0 or 1.

    3hamd.jpg2i0buza.jpg

    That's the code to create the Brush WrapMode subpallet in the Zplugin menu that contain a switch button named WrapMode: the button toggle the WrapMode of the selected brush between 0 and 1.
    [ISubPalette,"Zplugin:Brush WrapMode"]
    [IButton, "Zplugin:Brush WrapMode:WrapMode","Toggle brush WrapMode between 0 and 1",
    	[If,[IGet,Brush:Curve:WrapMode]=0,
    	[ISet,Brush:Curve:WrapMode,1]
    	,
    	[ISet,Brush:Curve:WrapMode,0]
    	]
    ]
    

    You can also directly download the plugin (that works on bot 32 & 64 bit) from here: https://www.dropbox.com/s/bj6pwr1i9ssir0o/Wrap_Mode_Toggle.zsc?dl=0

    I hope this helps. :)
  • Farfarer
    The best I managed was a script that auto-set wrap mode all the time - I think it was set up to apply it on mouse movement trigger? - although you had to be careful because some brush selection methods count as a script run and thus disables the script setting the wrap mode.

    So you had to activate the script and go through all the brushes you intended to use (the wrapmode gets saved with the brush, but only for the current instance of ZBrush) and then go on your merry way. Until you managed to pull up another brush :/

    I'm guessing you might be able to write a script to go through all the brushes and set wrap mode?
  • < ASH >
    Offline / Send Message
    < ASH > polycounter lvl 13
    Farfarer wrote: »
    The best I managed was a script that auto-set wrap mode all the time - I think it was set up to apply it on mouse movement trigger? - although you had to be careful because some brush selection methods count as a script run and thus disables the script setting the wrap mode.

    So you had to activate the script and go through all the brushes you intended to use (the wrapmode gets saved with the brush, but only for the current instance of ZBrush) and then go on your merry way. Until you managed to pull up another brush :/

    Hey Farfarer many thanks for the tip. :)
    Your solution sounds really interesting and possibly the most efficient one because removes the silly task to set the wrap mode for each brush one by one.

    However it sound dangerous as well (if it can interfere with the selection method of certain brushes). What is not clear to me is: once activated your script will be always on until you close ZBrush? Or is more like a toggle, like you turn the script on (that sets all the brush you select to WrapMode 1) and then you turn it off (meaning it stops affecting the mouse and the selection as well).
    I am not thatacknowledged about Zscripting yet and I have never messed up with the mouse functions so far (so I am not sure how it works). I will look into it asap to see what I can do. :)
    Farfarer wrote: »
    I'm guessing you might be able to write a script to go through all the brushes and set wrap mode?
    In effect this was my initial idea, then I though would be better to control the WrapMode for each brush instead of setting it globally, even because I still don't know how to affect all the brushes at once, I would need to do some research about it (I will have a look to the Pixologic documentation). :poly121:
  • < ASH >
    Offline / Send Message
    < ASH > polycounter lvl 13
    In the end following Fanfarer hints I managed to put together a script that toggle the WrapMode between 0 and 1 of a selected list of brushes (getting some help on Zbrush Central).

    That's the code, that can be customized according to your needs. :)

    The code beow creates the Brush WrapMode subpallet in the Zplugin menu that contain a button named WrapMode Main Brushes: the button toggle the WrapMode of the brushes listed below between 0 and 1. Obviously these are the brushes that I want to affect. you can add or remove the brushes and fix the brushCount number at the beginning of the script. :)
    [IConfig,4.73]
    
    [ISubPalette, "Zplugin:Brush WrapMode"]
    
    [VarSet, [COLOR="red"]brushCount[/COLOR], [COLOR="Red"]31[/COLOR]]
    [VarDef, brushes(brushCount), ""]
    [VarSet, brushes(0), "Brush:Morph"]
    [VarSet, brushes(1), "Brush:Standard"]
    [VarSet, brushes(2), "Brush:Dam_Standard"]
    [VarSet, brushes(3), "Brush:hPolish"]
    [VarSet, brushes(4), "Brush:Flatten"]
    [VarSet, brushes(5), "Brush:Planar"]
    [VarSet, brushes(6), "Brush:TrimDynamic"]
    [VarSet, brushes(7), "Brush:TrimAdaptive"]
    [VarSet, brushes(8), "Brush:TrimSmoothBorder"]
    [VarSet, brushes(9), "Brush:MalletFast"]
    [VarSet, brushes(10), "Brush:MalletFast2"]
    [VarSet, brushes(11), "Brush:Move"]
    [VarSet, brushes(12), "Brush:Move Elastic"]
    [VarSet, brushes(13), "Brush:Alpha"]
    [VarSet, brushes(14), "Brush:Clay"]
    [VarSet, brushes(15), "Brush:ClayBuildup"]
    [VarSet, brushes(16), "Brush:ClayTubes"]
    [VarSet, brushes(17), "Brush:Clay"]
    [VarSet, brushes(18), "Brush:ClayBuildup"]
    [VarSet, brushes(19), "Brush:ClayPolish"]
    [VarSet, brushes(20), "Brush:ajClay"]
    [VarSet, brushes(21), "Brush:ajPolish"]
    [VarSet, brushes(22), "Brush:ajNoise"]
    [VarSet, brushes(23), "Brush:Orb.Cracks"]
    [VarSet, brushes(24), "Brush:ajCracks"]
    [VarSet, brushes(25), "Brush:ajPinch"]
    [VarSet, brushes(26), "Brush:Pinch"]
    [VarSet, brushes(27), "Brush:Inflat"]
    [VarSet, brushes(28), "Brush:Magnify"]
    [VarSet, brushes(29), "Brush:CurveTubeSnap"]
    [VarSet, brushes(30), "Brush:CurveLineTube"]
    
    
    [IButton, "ZPlugin:brush WrapMode:WrapMode Main Brushes", "Toggle WrapMode of the Main Brushes between 0 an 1.",
    [IFreeze,
    // Store the currently selected 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]
    ]
    // First flip the WrapMode for the currently selected brush.
    [ISet, "Brush:Curve:WrapMode", newWrapMode]
    // Then flip your hardcoded brushes.
    [Loop, brushCount,
    [IPress, brushes(index)]
    [ISet, "Brush:Curve:WrapMode", newWrapMode]
    , index]]
    // And switch back to the original brush.
    [ISet, 30516, currentBrush]
    ]
    , /*DISABLED ?*/, /*BUTTON WIDTH*/, , /*BUTTON ICON*/, /*BUTTON HEIGHT*/]
    
  • < ASH >
    Offline / Send Message
    < ASH > polycounter lvl 13
    Hey people,

    with some help from the ZBrushCentral community (in particular Mark "TVeyes" that helped me with the most difficult code parts) I managed to perfect the code.
    In the previous version the WrapMode was not changed for the hardcoded Smooth and Masking brushes: in with this new version the Smooth and Masking brushes WrapMode is finally affected by the script as the regular sculpting brushes.

    The code below creates the Brush WrapMode subpallet in the Zplugin menu that contain a button named WrapMode Main Brushes: the button toggle the WrapMode of the brushes listed below between 0 and 1.
    Obviously the brushes hardcoded in the scipt below are the brushes that I want to affect: you can customize the script adding or removing the brushes you need.
    When adding or removing brushed remember to fix the brushCount number at the beginning of the script ( this number is meant to be the totale number of brushes +1, because you start counting from the brush 0).
    Also bear in mind that the brushType(#), # variable defines the type of brush that you are hard coding, as explained below:

    - brushType(#), 0: Modeling brush.
    Example below:
    [VarSet, brushes(1), "Brush:Standard"] [VarSet, brushType(1), 0]

    - brushType(#), 1: Smooth brush.
    Example below:
    [VarSet, brushes(29), "Brush:Smooth"] [VarSet, brushType(29), 1]

    - brushType(#), 2: Masking brush.
    Example below:
    [VarSet, brushes(32), "Brush:MaskPen"] [VarSet, brushType(32), 2]

    I hope this helps.  :)

    [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*/]
    
  • Stromberg90
    Offline / Send Message
    Stromberg90 polycounter lvl 11
    I also tried this a few weeks ago.
    This code loops trough all the brushes.

    The main problem is that a bunch of dialog boxes shows up.
    So hopefully someone else know how to fix this and can combine the scripts :)
    [IFreeze,
    [VarDef, wrapAmmount, 2]
    [VarDef, originalBrush, [IGet, Brush:ItemInfo]]
    [VarDef, brushCount, [IGetMax, Brush:ItemInfo]]
    [VarDef, currentBrush, 0]
    [Loop,brushCount,
         [VarSet, currentBrush, (currentBrush+1)]
         [ISet, Brush:ItemInfo, currentBrush]
         [ISet, Brush:Curve:WrapMode, wrapAmmount]
    ]
    [ISet, Brush:ItemInfo, originalBrush]]
    
  • < ASH >
    Offline / Send Message
    < ASH > polycounter lvl 13
    I also tried this a few weeks ago.
    This code loops trough all the brushes.

    The main problem is that a bunch of dialog boxes shows up.
    So hopefully someone else know how to fix this and can combine the scripts :)

    Yeah I know, those are the warnings that shows up when you select a Smooth/Mask/Trim/Slice/etc brush (basically any brush that needs a modifier to be activate).

    With he script above those warning don't show up, but honestly I haven't tackled that part of the code: Mark sort that out for me (cause I am not so acknowledge with ZScripting), so I can't tell you how to prevent those warnings to show up. :(
  • aintnobody
    Offline / Send Message
    aintnobody polycounter lvl 3
    Is it possible to smooth in wrap mode ? When I smooth, it does not tile anymore.
  • m4dcow
    Offline / Send Message
    m4dcow interpolator
    Is it possible to smooth in wrap mode ? When I smooth, it does not tile anymore.
    You need to set the wrap mode for the smooth brush too, just hold shift and go into the menu.
  • < ASH >
    Offline / Send Message
    < ASH > polycounter lvl 13
    As M4dcow said it is possible.
    The script I posted above already account for the 3 most used smooth brushes ("Smooth", "Smooth Valleys" and "Smooth Peaks") that are hard-coded in the script above:
    [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]
    Running the script the Smooth, the Smooth Valleys and the Smooth Peaks will get their wrap mode set to 1 as well.
    So after that simply press Shift and you will have the smooth brush working with Wrapmode as well.
  • azchtein
    Offline / Send Message
    azchtein polycounter lvl 6
    i tried on 4r7 p3 64 the button didn`t work, am i missing something?
  • < ASH >
    Offline / Send Message
    < ASH > polycounter lvl 13
    azchtein said:
    i tried on 4r7 p3 64 the button didn`t work, am i missing something?
    Hey azchtein sorry for the late reply, I almost never check this thread anymore.
    Can you be more specific? Which one of the 2 scripts doesn't work?

    The WrapMode button (that toggle the Wrap Mode on  the selected brushes) or the more complex Brush List Wrap Mode (that toggle the Wrap Mode on all the brushes specified in the script)? 
    I am still using both scripts on both ZBrush 4r7 p3 x64 and also on the new ZBrush 4r8 and they work fine.

    If you provide me more details I might be able to figure out what's wrong with it. :)
Sign In or Register to comment.