1. #1
    Member Follow User Gallery
    Join Date
    Mar 2012
    Location
    Dallas, TX
    Posts
    30

    Default Polypaint toggle button

    This works for the first 8 subtools in the list (as long as I haven't scrolled down). It doesn't work on any other subtool. Why? I believe it has something to do with SubToolGetActiveIndex.

    I'm stumped. Thanks.

    [CODE]//Create button[IButton,"PolyPnt Sel","Toggle PolyPaint On/Off for ACTIVE subtool",
    [IFreeze,
    [IShowActions,0]
    //Create variable for polypaint state (On or Off?)
    [VarDef,ppStateSel,0]

    //Create variable to store currently selected subtool
    [VarSet,activeSubT,[SubToolGetActiveIndex]]


    //Put polypaint state/value into variable
    [VarSet,ppStateSel,[IModGet,[StrMerge,"Tool:Subtool:Subtool ",#activeSubT]]]


    //If on, turn off ... If off, turn on
    [If,ppStateSel = 25, //Vis On,PP On
    [IUnPress,Tool:Polypaint:Colorize] //turn PP off
    ]

    [If,ppStateSel = 17, //Vis On,PP Off
    [IPress,Tool:Polypaint:Colorize] //turn PP On
    ]

    [If,ppStateSel = 9, //Vis Off,PP On
    [IUnPress,Tool:Polypaint:Colorize] //turn PP Off
    ]

    [If,ppStateSel = 1, //Vis Off,PP Off
    [IPress,Tool:Polypaint:Colorize]
    ]


    ]//end freeze
    [IShowActions,-1]
    ,,.5
    ]//end PP Toggle button[/CODE]
    Last edited by ijacobs; 12-12-12 at 04:22 PM.

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

    Default

    You can't use the active index like that. The reason is that it will give you the subtool index in the list from 0 to (total number of subtools minus 1), whereas the number in the path to the selected subtool will only be from 0 - 7.

    You can use the name of the subtool instead, like this (though note that you might get unexpected results if there are duplicate subtool names):

    [CODE]
    [VarSet,activeSubT,[SubToolGetActiveIndex]]
    //this makes sure there is no error if the active subtool is hidden
    [If,([Val,activeSubT+1] == [SubToolGetCount] ),
    [SubToolSelect,0]
    ,
    [SubToolSelect,[Val,activeSubT+1]]
    ]
    [SubToolSelect,activeSubT]
    [VarSet,subToolPath,[IGetTitle,Tool:Item Info]]//get subtool name
    [VarSet,subToolPath,[StrExtract,subToolPath,0,[StrLength,subToolPath]-2]]//trim off period
    [VarSet,ppStateSel,[IModGet,[StrMerge,"Tool:Sub Tool:",subToolPath]]]

    //If on, turn off ... If off, turn on
    [If,ppStateSel = 25, //Vis On,PP On
    [IUnPress,Tool:Polypaint:Colorize] //turn PP off
    ]

    [If,ppStateSel = 17, //Vis On,PP Off
    [IPress,Tool:Polypaint:Colorize] //turn PP On
    ]

    [If,ppStateSel = 9, //Vis Off,PP On
    [IUnPress,Tool:Polypaint:Colorize] //turn PP Off
    ]

    [If,ppStateSel = 1, //Vis Off,PP Off
    [IPress,Tool:Polypaint:Colorize]
    ][/CODE]

    The first bit of code is necessary to make sure the active subtool is visible in the subtool list. If the subtool is hidden you will get an error when trying to use IModGet saying the item 'does not have special modifiers'.

Posting Permissions

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