Hi
I want to build my own toggle switch for lock selected and key slected or unlock , to do that i just simply want to click a button to toggle in shelf so that if i select any attribute of the object i should be able to lock or unlock just with a click rather than doing right cliock and lock selected..please help...
Replies
Welcome to polycount btw. Did you try just dissecting the output in the script editor from doing it manually?
string $sel[] = `ls -sl`; string $selectChannels[] = `channelBox -q -selectedMainAttributes mainChannelBox`; if(`size $selectChannels`!=0 && `size $sel` != 0){ for($thisObj in $sel){ for ($thisChannel in $selectChannels){ setAttr -lock (!`getAttr -l ($thisObj + "." + $thisChannel)`) ($thisObj + "." + $thisChannel); } } } else { warning("Please select an object and the channels you want to lock"); }Just wrote this up , should toggle the current selected attribute to locked and unlocked. If you wanted to build something else the command your looking for is:
channelBox -q -selectedMainAttributes mainChannelBox
also i believe its better to use "!" mark to make a check rather then using an if statement, that makes it easier to put the getAttr inside the setAttr
just one more basic ques how does $thisChannel selects once channel at a time from $selectChannels ? is it what for loop is doing, coz its iterating. the the max in selection.