1. #1
    Senior Member User Gallery
    Join Date
    May 2007
    Location
    Raleigh NC
    Posts
    450

    Default Question: How to make a toggle button?

    So I know very little about scripting but I made a couple macros. One to turn Colorize "ON" for all subtools and another to turn Colorize "OFF" for all subtools. I was wondering if there was a way to just make it a toggle so I could just have one button? Attached is the macro.

    Also, I was wondering if that toggle could be used for slider values? For example I wanted to make a toggle for the brush setting "Automask by Polygroups." It's is a slider from 0 to 100. The button would toggle the value between 0 and 100.
    Attached Files Attached Files

  2. #2
    Moderator User Gallery
    Join Date
    Jun 2004
    Location
    UK
    Posts
    7,670

    Default

    All you need to do is put in a test so that if the button or slider is in one state then your macro sets the other state. You use the [If statement like this:

    Code:
    [If,[IGet,Tool:Polypaint:Colorize] == 1,//the button will return 1 if it's on
    [IUnPress,Tool:Polypaint:Colorize]
    ,//else it's off so turn it on	
    [IPress,Tool:Polypaint:Colorize]
    ]
    and for the brush masking

    Code:
    [If,[IGet,Brush:Auto Masking:Mask By Polygroups] == 0,
    [ISet,Brush:Auto Masking:Mask By Polygroups,100]
    ,//else set to zero
    [ISet,Brush:Auto Masking:Mask By Polygroups,0]
    ]
    Note that the brush masking toggle will turn off if the slider is set to any value above 0.

    HTH,

  3. #3
    Senior Member User Gallery
    Join Date
    May 2007
    Location
    Raleigh NC
    Posts
    450

    Default

    Man this is awesome. The colorize toggle worked perfectly! You made me very happy Marcus.

    I tried the brush masking code but it didn't seem to work. Is there something else I have to add to it?

  4. #4
    Moderator User Gallery
    Join Date
    Jun 2004
    Location
    UK
    Posts
    7,670

    Default

    I'm sorry, I cut and pasted the code and managed to introduce a couple of extra brackets. Try again, I've corrected it. If it still doesn't work, post your macro and I'll take a look.

  5. #5
    Senior Member User Gallery
    Join Date
    May 2007
    Location
    Raleigh NC
    Posts
    450

    Default

    Yea I wasn't able to get it to work.
    Attached Files Attached Files

  6. #6
    Moderator User Gallery
    Join Date
    Jun 2004
    Location
    UK
    Posts
    7,670

    Default

    I only posted a code snippet - you need to have a button for the macro to appear (and work). Try this version.
    Attached Files Attached Files

  7. #7
    Senior Member User Gallery
    Join Date
    May 2007
    Location
    Raleigh NC
    Posts
    450

    Default

    Ah right, Thank you so much! This is really awesome.

  8. #8
    Senior Member User Gallery
    Join Date
    Oct 2005
    Location
    USA
    Age
    29
    Posts
    825

    Default

    Is it possible to have zbrush remember the toggle state so that when you restart zbrush the toggle button is always on or off?

    Thanks

  9. #9
    Moderator User Gallery
    Join Date
    Jun 2004
    Location
    UK
    Posts
    7,670

    Default

    Quote Originally Posted by --E--
    Is it possible to have zbrush remember the toggle state so that when you restart zbrush the toggle button is always on or off?
    Yes, but you have to be careful. The macro (or plugin) sets the state on start up having read the value from a file. If you try to set an interface item that isn't present when ZBrush launches then you could get an error (for example, the activate symmetry button which only becomes available when a 3D tool is selected).

    Anyhow, the attached macro shows the basic idea.
    Attached Files Attached Files

  10. #10
    Senior Member User Gallery
    Join Date
    Oct 2005
    Location
    USA
    Age
    29
    Posts
    825

    Default

    Holy crap that is amazingly awesome! It works perfectly! Thank you so much Marcus!

  11. #11
    Moderator User Gallery
    Join Date
    Jun 2004
    Location
    UK
    Posts
    7,670

    Default

    Eric,

    Here's another way to do toggles which may interest you:

    http://www.zbrushcentral.com/showpos...3&postcount=52

Posting Permissions

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