Home Coding, Scripting, Shaders

Maxscript - how to refresh UI?

greentooth
Offline / Send Message
pxgeek greentooth
I have a maxscript bound to a hotkey that lets me toggle the visibility of my currently selected modifier in the stack...but it won't update the eyeball icon unless I interact with the command panel in some way.

I did find this little snippet:  colorMan.reinitIcons() 
that does the job, except it also automatically reselects to the top of the stack, which makes the toggle kind of useless.

Is there another way to do this?

I may as well post said script here since I'm pretty sure I found it on cgsociety :'(

(
    CurrentMod = modpanel.getCurrentObject()
    theModifier_ID = modPanel.getModifierIndex $ CurrentMod
        ($.modifiers[theModifier_ID].enabled = NOT $.modifiers[theModifier_ID].enabled)
     )

Replies

  • PolyHertz
    Offline / Send Message
    PolyHertz polycount lvl 666
    You have to set the selected modifier again for the icon to refresh. Here's some simple changes to fix the icon issue and prevent some potential errors:


    if classof subobjectlevel != Integer do setCommandPanelTaskMode #modify
    theObjs = selection as array
    if theObjs.count > 0 do (
        CurrentMod = modpanel.getCurrentObject()
        if superclassof CurrentMod == modifier do (
            theObj = theObjs[1]
            theModifier_ID = modPanel.getModifierIndex theObj CurrentMod
            theObj.modifiers[theModifier_ID].enabled = NOT theObj.modifiers[theModifier_ID].enabled
            modPanel.setCurrentObject theObj.modifiers[theModifier_ID]
        )
    )
  • pxgeek
    Offline / Send Message
    pxgeek greentooth
    You're awesome PolyHertz, Thank you!!
  • Klunk
    Offline / Send Message
    Klunk ngon master
    I know polyhertz has provided the best solution... I found an interesting solution while trying to force another part of a modifier ui to update (when pressing a toolbar button)
    (
        CurrentMod = modpanel.getCurrentObject()
        theModifier_ID = modPanel.getModifierIndex $ CurrentMod
        ($.modifiers[theModifier_ID].enabled = NOT $.modifiers[theModifier_ID].enabled)
        notifyDependents (refs.dependents $)[1] 
        modPanel.setCurrentObject $.modifiers[theModifier_ID]
    )
    should force the whole mod panel to redraw, I've absolutely no idea why it works :astonished:

  • denisT
    (
    <modifier>.enabled = <enabled>
    notifydependents <modifier> partid:0 msg:0x0211
    )

Sign In or Register to comment.