I notice many people with plugins that have a on/off toggle like with zbrush smt for subdividing.
How can I create a similar button?
I found this code
[ISubPalette,ZPlugin:ProxyTest1,0,0,0,0]
[IConfig,4.31]
[IShowActions, 0]
[ISwitch, āZPlugin:ProxyTest1:TopoMaskā ,
[IGet, Brush:Auto Masking:Topological],
āTopo Maskā,
[ISet, Brush:Auto Masking:Topological, 1],
[ISet, Brush:Auto Masking:Topological, 0],
0,
.5]
[IEnable,āZPlugin:ProxyTest1:TopoMaskā]
But the first time i click it it does nothing, have to click twice to get it going how can i fix that bug?
The problem is because the first click loads the plugin and the switch state is set to reflect the state of the Topological button. If the states are reversed then the button will work first time:
[ISubPalette,ZPlugin:ProxyTest1,0,0,0,0]
[IConfig,4.31]
[IShowActions, 0]
[VarDef,startupState,0]
[RoutineDef,Startup,
[If,[IExists,āZPlugin:ProxyTest1:TopoMaskā],
[VarSet,winID,[IGet,Preferences:Utilities:View Window Id]]
[If,[IGet, Brush:Auto Masking:Topological]==1,
[VarSet,startupState,0]
,
[VarSet,startupState,1]
]
]
]
[RoutineCall,Startup]
[ISwitch, āZPlugin:ProxyTest1:TopoMaskā ,
startupState,
āTopo Maskā,
[ISet, Brush:Auto Masking:Topological, 1],
[ISet, Brush:Auto Masking:Topological, 0],
0,
.5]
[IEnable,āZPlugin:ProxyTest1:TopoMaskā]
Note that if your plugin had more than one switch then code would be necessary to find which switch was being pressed.
Thanks this is a great!
I realise I put in some code thatās not needed in this case - where the winID variable is set. Thatās how you can tell which button is clicked if you have more than one. Youād then compare the winID with the numerical ID for the button (using [IGetID]). When it returns true, thatās the button the user has clicked.