1. #1
    Senior Member Follow User Gallery
    Join Date
    Jun 2007
    Posts
    234

    Default Hide subtool under mouse

    hi guys. i'm looking to create a script that will ( as the thread title says ) hide the subtool under mouse ( location ). the idea being that it would use that aspect similar to marcus' AutoSelectSubTool ( essentially echoing a mouse click under the position of the cursor ) and turn off the visibility ( eye ) of that subtool

    in loose macro form :

    hit the key ( hotkeyed macro ). the current subtool is stored as var0
    the subtool you want to hide is ( ' selected ' and ) stored as var1
    script switches back to var0 and hides var1

    .

    if anyone has a script similar. or know of some functionality i'm missing that achieves the same thing i would be hugely grateful for any help

    thanks

  2. #2

    Default

    [CODE]//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 !!
    ] [/CODE]

    so. putting that into this loose macro form. it works sometimes, and yet others spits the error :



    here i just lifted the IPress from a zb macro and replaced with the variable. if anyone can hint as to where i've messed up then thanks heaps

    .

  3. #3
    Moderator Follow User Gallery
    Join Date
    Jun 2004
    Location
    UK
    Posts
    11,462

    Default

    This is quite complex because you need to make sure that the subtool is visible in the subtool list before trying to 'press' it. So you need to find the active subtool in a slightly different way. The code shows one method. This positions the scrollbar so that the subtool at position '0' is tested to see if it is the active subtool. This is only necessary when there are more than 8 subtools, as with 8 or less all subtools are always visible in the list.

    This also uses the string compare method to test for the active subtool so it isn't turned off (though this could fail if there were two subtools of the same name).

    [CODE]
    //store the scrollbar position
    [VarSet,tmpScrollPos,[IGetSecondary,Tool:Sub Tool:SubTool ScrollBar]]

    //find the selected subtool
    [VarSet,totalSubTools,[StrExtract,[IGetTitle,Preferences:Misc:SubTools Count],10,256]]
    [If,totalSubTools>8,
    [VarSet,i,1]
    [VarSet,subToolPath,"Tool:Sub Tool:SubTool 0"]
    [Loop,totalSubTools,
    [VarSet,scrollPos,(totalSubTools-i)]
    [ISet,Tool:Sub Tool:SubTool ScrollBar,0,scrollPos]
    [If,[IGetFlags,#subToolPath]>=9,
    [VarSet,activeSubT,[IGetTitle, Tool:Current Tool]]
    [LoopExit]
    ]
    [VarInc,i]
    ]
    ,
    [VarSet,scrollPos,tmpScrollPos]
    [Loop,totalSubTools,
    [VarSet,subToolPath,[StrMerge,"Tool:Sub Tool:SubTool ",[Val,n]]]
    [If,[IGetFlags,#subToolPath]>=9,
    [VarSet,activeSubT,[IGetTitle, Tool:Current Tool]]
    [LoopExit]
    ]
    ,n]
    ]


    //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,hideSubT,[IGetTitle, Tool:Current Tool]]

    //hide var1

    [If,([StrLength,hideSubT]==[StrLength,activeSubT])&&([StrFind,hideSubT,activeSubT]>-1),

    //active subtool - do nothing
    ,
    //if it's not the active subtool
    [IModSet,[StrMerge,"Tool:SubTool:",hideSubT],1]
    ]


    //switch back to selected subtool
    //set the scrollbar so subtool shows
    [ISet,Tool:Sub Tool:SubTool ScrollBar,0,scrollPos]

    //select subtool
    [IPress,#subToolPath]

    //reset scrollbar
    [ISet,Tool:Sub Tool:SubTool ScrollBar,0,tmpScrollPos]
    [/CODE]

    HTH,

  4. #4
    Moderator Follow User Gallery
    Join Date
    Jun 2004
    Location
    UK
    Posts
    11,462

    Default

    I meant to add that you only need to press and unpress the Preferences:Edit:Auto Select SubTool if you have that option turned off by default (perhaps because you are using my AutoSelect SubTool macro). Otherwise you will be left without the ability to Alt+click a subtool to select it.

  5. #5
    Member Follow User Gallery
    Join Date
    Nov 2006
    Location
    Ontario,Canada
    Posts
    98

    Default

    used to use this all the time...r8 kicks up an error now ...anyone else have a similar script or can fix this one to work in r8?

    SCRIPT: HideSubtoolUnderMouse.txt

    ERROR: #subToolPath
    IN: [IPress,#subToolPath]


    MrOneTwo said:

    I actually got it working. It's definately not perfect. There is a bug which is based on Alt + LMB subtool changing. I hacked a solution by changing a subtool to a one above on the list and then back to the one that is selected = it does nothing. It only fixes the Alt + LMB issue. Also because of this hack when you use it while first subtool is the active one it doesn't select it after hiding the other one. It selects the one below.

    The one time triggering is described in Zbrush scripting docs. It's intentional (if you are loading script through z scripting palette). I compiled it into a button and threw it into ZStartup folder and now it works ok. Here is the code (unhiding doesn't work for now):

    [ISubPalette,"ZPlugin:Hide"]

    [IButton,"ZPlugin:Hide:Toggle Vis","Toggle subtool visibility",
    [IConfig,4.6]
    [IPress,Tool:SubTool:SelectUp]
    [IPress,Tool:SubTool:SelectDown]
    //store the scrollbar position
    [VarSet,tmpScrollPos,[IGetSecondary,Tool:Sub Tool:SubTool ScrollBar]]
    //find the selected subtool
    [VarSet,totalSubTools,[StrExtract,[IGetTitle,Preferences:Misc:SubTools Count],10,256]]
    [If,totalSubTools>8,
    [VarSet,i,1]
    [VarSet,subToolPath,"Tool:Sub Tool:SubTool 0"]
    [Loop,totalSubTools,
    [VarSet,scrollPos,(totalSubTools-i)]
    [ISet,Tool:Sub Tool:SubTool ScrollBar,0,scrollPos]
    [If,[IGetFlags,#subToolPath]>=9,
    [VarSet,activeSubT,[IGetTitle, Tool:Current Tool]]
    [LoopExit]
    ]
    [VarInc,i]
    ]
    ,
    [VarSet,scrollPos,tmpScrollPos]
    [Loop,totalSubTools,
    [VarSet,subToolPath,[StrMerge,"Tool:Sub Tool:SubTool ",[Val,n]]]
    [If,[IGetFlags,#subToolPath]>=9,
    [VarSet,activeSubT,[IGetTitle, Tool:Current Tool]]
    [LoopExit]
    ]
    ,n]
    ]
    //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,hideSubT,[IGetTitle, Tool:Current Tool]]
    //hide var1

    [If,([StrLength,hideSubT]==[StrLength,activeSubT])&&([StrFind,hideSubT,activeSubT]>-1),
    //active subtool - do nothing
    ,//if it's not the active subtool
    [IModSet,[StrMerge,"Tool:SubTool:",hideSubT],1]
    ]

    //switch back to selected subtool
    //set the scrollbar so subtool shows
    [ISet,Tool:Sub Tool:SubTool ScrollBar,0,scrollPos]
    //select subtool
    [IPress,#subToolPath]
    //reset scrollbar
    [ISet,Tool:Sub Tool:SubTool ScrollBar,0,tmpScrollPos]
    ]


    // unhide all
    [IButton,"ZPlugin:Hide:Unhide All","Unhide all subtools.",
    [IConfig,4.6]
    [VarSet,tmpScrollPos,[IGetSecondary,Tool:Sub Tool:SubTool ScrollBar]]
    [VarDef, SubToolNumber,0] //variable to store number of subtools
    [VarDef, CurrentSubtoolName,""]


    [VarSet, SubToolNumber,[SubToolGetCount]] // Get number of subtool and assign it to SubToolNumber var

    [Loop, SubToolNumber, //loop through each subtool

    [subToolSelect, n]

    [VarSet, CurrentSubtoolName,[IGetTitle, Tool:ItemInfo]] // assign name of currentsubT to CurrentSubtoolName

    [IModSet,[StrMerge,"Tool:SubTool:",CurrentSubtoolName],17]
    [ISet,Tool:Sub Tool:SubTool ScrollBar,0,tmpScrollPos]


    ,n]

    ]
    Zscript syntax blows... at least for some one who codes in C/C++ and Python...

  6. #6
    Moderator Follow User Gallery
    Join Date
    Jun 2004
    Location
    UK
    Posts
    11,462

    Default

    This will turn off the subtool under the mouse. Obviously you need to assign a hotkey. It's a macro, so should be saved to the ZBrush 4R8\ZStartup\Macros\Misc folder but it's straightforward to change it into a plugin if you wish.

    For Inverting Visible subtools, Show/Hiding subtools and Toggling the Top subtool, see the SubTool Master plugin.

    Off SubTool.txt

  7. #7

  8. #8
    Senior Member Follow User Gallery
    Join Date
    Mar 2011
    Location
    Schaumburg IL
    Age
    30
    Posts
    382

    Default

    hey marcus, this doesn't seem to work on on certain tools/subtools if the file has folders.

    EDIT: thank you marcus it works now.

  9. #9
    Moderator Follow User Gallery
    Join Date
    Jun 2004
    Location
    UK
    Posts
    11,462

    Default ZBrush 2019 version

    Try this version:
    Off SubTool_2019.txt

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •