View Full Version : any zScripting buffs among us ?
tacit math
10-27-2011, 04:27 PM
hey guys. if any of you can offer any help here that would be awesome. knocked up this quick script. patched together from simple macro recording etc :
//ZBRUSH MACRO - Recorded in ZBrush version 4.2
[IButton,???,"Press to run this macro. Macros can be aborted by pressing the ëescí key.",
[IShowActions,0]
[IConfig,4.2]
//
//define vars
[VarDef, SubToolTitle_0,"null"]
[VarDef, SubToolTitle_1,"null"]
//
//set var0 to current tool
[VarSet,SubToolTitle_0,[IgetTitle, Tool:Current Tool]]
//
//do select. . . ( marcus civis )
[IPress,Preferences:Edit:Auto Select SubTool]
[IKeyPress,1064,[CanvasClick,[MouseHPos],[MouseVPos]]]
[IUnPress,Preferences:Edit:Auto Select SubTool]
//
//and then set var1 to that selection
[VarSet,SubToolTitle_1,[IgetTitle, Tool:Current Tool]]
//
//hide var1
[IModSet,[StrMerge,"Tool:SubTool:",SubToolTitle_1],1]
//
//switch back to var0
[IPress,[StrMerge,"Tool:SubTool:",SubToolTitle_0]]
//
//PIOW !!
]
the intended functionality is to hide the subtool under the mouse ( so the macro has to be hotkeyed ). it works at times and at others i get the error :
http://dl.dropbox.com/u/3436831/zError.png
i'm less even than a noob when it comes to zScripting and / so the fact that it works perfectly sometimes. then not. leaves me at a bit of a loss. gonna have a look at my strings and see if zb shits at odd characters etc. but otherwise. . .
.
any thoughts ?
BeatKitano
10-27-2011, 06:52 PM
Nevermind didn't read carefully enough.
tacit math
10-30-2011, 03:21 PM
just bumping this guy in the hope of finding a solution
Funky Bunnies
10-30-2011, 05:19 PM
hey Tacit, I just tried my hand at this... I think you're the only reason I've ever messed with zbrush macros haha. cool idea though
anyway I've only mucked about for a bit but I think the problem is that on larger subtool lists the original subtool is no longer in the range of the scrollbar.
Edit:
So I opted to manipulate the scrollbar because that seems to be the accepted way to solve this problem. Now it'll toggle visibility on the current subtool, and turn off others you hover on
//ZBRUSH MACRO - Recorded in ZBrush version 4.2
[IButton,???,"Press to run this macro. Macros can be aborted by pressing the ëescí key.",
[IShowActions,0]
[IConfig,4.2]
//
//define vars
[VarDef, InitSubtool,"null"]
[VarDef, HoverSubtool,"null"]
//
//set hoverSubtool to current tool
[VarSet,InitSubtool,[IgetTitle, Tool:Current Tool]]
//
//do select. . . ( marcus civis )
[IPress,Preferences:Edit:Auto Select SubTool]
[IKeyPress,1064,[CanvasClick,[MouseHPos],[MouseVPos]]]
[IUnPress,Preferences:Edit:Auto Select SubTool]
//
//and then set initSubtool to that selection
[VarSet,HoverSubtool,[IgetTitle, Tool:Current Tool]]
//just a note to see what all's being selected...
//[Note, [StrMerge,"hide subtool:", #HoverSubtool, "...then reselect subtool:", #InitSubtool]]
//now do all the overly convoluted nonsense
//
[VarSet,totalSubTools,[StrExtract,[IGetTitle,Preferences:Misc:SubTools Count],10,256]]
[If,(([StrLength,#InitSubtool] == [StrLength,#HoverSubtool])&&([StrFind,#HoverSubtool,#InitSubtool]>-1)),
//then both the init and hover subtools are hte same, so toggle visibility
[IClick,[StrMerge,"Tool:SubTool:",HoverSubtool],[IWidth,[StrMerge,"Tool:SubTool:",HoverSubtool]]-10,5]
//else just toggle visibility of the one subtool...
,
//hide initSubtool
[IModSet,[StrMerge,"Tool:SubTool:",HoverSubtool],1]
//now switch back to hoverSubtool
[ISet,Tool:Sub Tool:SubTool ScrollBar,0,(totalSubTools-1)]
//loop through subtool scrollbar to find the InitSubtool
[Loop,totalSubTools,
[ISet,Tool:Sub Tool:SubTool ScrollBar,0,(totalSubTools-1-Iterate)]
[If, [Iexists, [StrMerge,"Tool:SubTool:",InitSubtool]],
[IPress,[StrMerge,"Tool:SubTool:",InitSubtool]]
[LoopExit]
]
,Iterate]
]
//
//PIOW !!
]
tacit math
10-31-2011, 12:09 AM
Bunnies you dirty bloody wizard. bit of lag but so far so long as i'm mouseOvered a tool it'll do the trick. takes a dump if nothing is there to be selected of course. i'll tinker with some conditionals ( the best option i reckon would be to unhide everything in that case. since i'd need to setup that key at some point )
i absolutely concede ignorance here but. man. that feels like some pretty clunky shit if it's required that the scrollbar be in a given position to work
anyway. as is this seems functional. thanks so much for your help a. object management in zb is still fucking stupid so this will be huge workflow boost
Funky Bunnies
10-31-2011, 02:35 AM
ah i see what you mean, I edited the script for one way to hopefully do what you were thinking
man this language is so bonkers I can hardly believe it haha
tacit math
10-31-2011, 02:39 AM
what you did bro works perfectly. my attempts at the conditional though. . . you'd think it would be as simple as comparing the two var strings
but. grr. such does not seem to be the case
Funky Bunnies
10-31-2011, 02:42 AM
yeah I was actually bashing my head trying to figure out how to compare strings for the last half hour -_-
lemme know if you have any problems yo!
tacit math
10-31-2011, 02:48 AM
well. i've juggled a ton of options thus far. nothing. when you run a note ( for example ) on var0 and var1 you get the name of each. a string. why the fuck then is the conditional not simply :
[If, SubToolTitle_1 == SubToolTitle_0
,
//do this
,
//else. do this
]
Funky Bunnies
10-31-2011, 02:55 AM
oh yeah, did you see the conditional I had to put in?
I wish it'd compare the string for you, it's pretty weird for a scripting language haha
[If,(([StrLength,#InitSubtool] == [StrLength,#HoverSubtool])&&([StrFind,#HoverSubtool,#InitSubtool]>-1)),
//Do this
stuff,
//else do this
stuff
]
tacit math
11-04-2011, 04:59 AM
//ZBRUSH MACRO - Recorded in ZBrush version 4.2
[IButton,???,"Press to run this macro. Macros can be aborted by pressing the ëescí key.",
[IShowActions,0]
[IConfig,4.2]
//
//define vars
[VarDef, SubToolTitle_0,""]
[VarDef, SubToolTitle_1,""]
//set var0 to current tool
[VarSet,SubToolTitle_0,[IgetTitle, Tool:Current Tool]]
//do select. . . ( thanks marcus civis )
[IPress,Preferences:Edit:Auto Select SubTool]
[IKeyPress,1064,[CanvasClick,[MouseHPos],[MouseVPos]]]
[IUnPress,Preferences:Edit:Auto Select SubTool]
//and then set var1 to that selection
[VarSet,SubToolTitle_1,[IgetTitle, Tool:Current Tool]]
//do check is same ( or ' null ' ). . . ( thanks marcus civis )
[If,([StrLength,SubToolTitle_1]==[StrLength,SubToolTitle_0])&&([StrFind,SubToolTitle_1,SubToolTitle_0]>-1)
,
//if true > running that dirty emulation of ui clicks. lifted from another script. . . ( thanks marcus civis )
[VarSet,btnWidth,[IWidth,[StrMerge,"Tool:SubTool:",SubToolTitle_0]]-10]//get the width of the button less 10 pixels
[IClick,[StrMerge,"Tool:SubTool:",SubToolTitle_0],btnWidth,5]//click the subtool 'eye' < once
[IClick,[StrMerge,"Tool:SubTool:",SubToolTitle_0],btnWidth,5]//click the subtool 'eye' < twice
,
//if false > run hiding off code
//hide var1
[IModSet,[StrMerge,"Tool:SubTool:",SubToolTitle_1],1]
//switch back to var0
//THANKS BUNNIES ( http://www.funkybunnies3d.com/ )
[IPress,Tool:SubTool:List All]
[IPress,[StrMerge,"PopUp:",SubToolTitle_0]]
//ends
]
//PIOW !!
]
this is ugly. but in all its hacked to shit and filthy glory seems to work. if anyone's interested make a macro of it and assign it to a key
NOTE : it will turn off prefs > Auto Select Subtool so if you use that function. tweak the script to turn it back on ( or use marcus civis Auto Select Subtool macro as a hotkey to do your subtool switching )
USAGE ( once the script is macro'ed and hotkey'ed ) :
> hit the key over the subtool you want to hide
> hit the key over current subtool or null / canvas space to unhide all subtools
.
gonna be a big workflow improvement if it doesn't reveal any quirks later
Funky Bunnies
11-04-2011, 11:28 PM
hey tacit, so it looks like the only differences between our scripts are:
you press the visibility button twice on currentSubtools? what's the benefit to this rather than having a toggle?
and you use the popup again instead of a loop? is this just for cleanliness?
I really don't know much about Zscript so I figured I'd ask so I know next time I want to try it out :)
tacit math
11-05-2011, 02:15 AM
man i doubt there's any benefit in any of the ways this is hacked in. 'cept for it's the shortest route i could piece together to achieve the functionality
it would need a more elegant write up with a bunch of checks in place to overcome its failings ( 1 being if the eye of your current sub is off. won't work. 2 the most significant. fails with subtools of same name ) and yours is likely very much closer to that. but i'm quite reluctant to sink any further time into this scripting language. once you see you have to programmatically shift the scrollbar to have access to other subtools ( ?!? ). well. fuck off right
vBulletin® v3.8.4, Copyright ©2000-2013, Jelsoft Enterprises Ltd.