macroScript LockSkinWeights category:"Grants" ( -- Description: Util for locking the weights of skin vertices. -- Created: 2000.10.15 -- Modified: 2000.10.30 -- Author: Grant Adam grant@optushome.com.au -- version: 1.1 try (destroyDialog Lock_verts) catch() -- this is up here since it doesn't always work at the end rollout Lock_verts "Lock Skin Weights" ( local skin_index local numvrt local tmp_weight_array local weight_array local sel_arr fn prep_skin = ( try ( skin_index = modPanel.getModifierIndex $ (modpanel.getCurrentObject()) numvrt = (skinOps.GetNumberVertices $.modifiers[skin_index]) ) catch(messagebox "Need to have a skin selected in the modify panel") ) fn get_weights = ( for i in 1 to numvrt do ( for j in 1 to skinOps.getNumberBones $.modifiers[skin_index] do ( try ( if (skinOps.GetVertexWeight $.modifiers[skin_index] i j) != undefined then ( append tmp_weight_array (skinOps.GetVertexWeight $.modifiers[skin_index] i j) ) ) catch(append tmp_weight_array "z") ) append weight_array tmp_weight_array tmp_weight_array = #() ) ) fn get_weights_sel = ( for i in 1 to numvrt do ( if (skinOps.isVertexSelected $.modifiers[skin_index] i == 1) then ( append sel_arr i for j in 1 to skinOps.getNumberBones $.modifiers[skin_index] do ( try ( if (skinOps.GetVertexWeight $.modifiers[skin_index] i j) != undefined then ( append tmp_weight_array (skinOps.GetVertexWeight $.modifiers[skin_index] i j) ) ) catch(append tmp_weight_array "z") ) append weight_array tmp_weight_array tmp_weight_array = #() ) ) ) button lavw "Lock All Vertex Weights" width:160 offset:[-3,0] button lsvw "Lock Selected Vertex Weights" width:160 offset:[-2,0] button rstall "Reset All Vertex Weights" width:160 offset:[-3,5] button rstsel "Reset Selected Vertex Weights" width:160 offset:[-0,0] on lavw pressed do ( disableSceneRedraw() try ( prep_skin() weight_array = #() tmp_weight_array = #() bone_array = #() n = skinOps.getNumberBones $.modifiers[skin_index] for m in 1 to n do ( append bone_array (skinOps.GetBoneName $.modifiers[skin_index] m 1) ) -- this gets the weights of all vertices currently get_weights() -- this then sets the same values back which flags them as changed for i in 1 to weight_array.count do ( skinOps.setVertexWeights $.modifiers[skin_index] i bone_array weight_array[i] ) ) catch() enablesceneredraw() redrawviews() ) on lsvw pressed do ( disableSceneRedraw() try ( prep_skin() weight_array = #() tmp_weight_array = #() bone_array = #() sel_arr = #() n = skinOps.getNumberBones $.modifiers[skin_index] for m in 1 to n do ( append bone_array (skinOps.GetBoneName $.modifiers[skin_index] m 1) ) -- this gets the weights of all selected vertices get_weights_sel() -- this then sets the same values back which flags them as changed for i in 1 to sel_arr.count do ( skinOps.setVertexWeights $.modifiers[skin_index] sel_arr[i] bone_array weight_array[i] ) ) catch() enablesceneredraw() redrawviews() ) on rstall pressed do ( disableSceneRedraw() -- try -- ( prep_skin() sel_arr = #() all_vert_array = #() -- now I store the currently selected vertices for i in 1 to numvrt do ( if (skinOps.isVertexSelected $.modifiers[skin_index] i == 1) then ( append sel_arr i ) ) -- select all vertices via bitarray then reset them skinOps.SelectVertices $.modifiers[skin_index] #{1..numvrt} skinOps.resetSelectedVerts $.modifiers[skin_index] -- then retrieve original selection, the enable/redraw views is needed here else fails enablesceneredraw() redrawviews() skinOps.SelectVertices $.modifiers[skin_index] sel_arr -- ) -- catch() enablesceneredraw() redrawviews() ) on rstsel pressed do ( try ( prep_skin() skinOps.resetSelectedVerts $.modifiers[skin_index] ) catch() ) )-- end --try (destroyDialog Lock_verts) catch() -- this doesn't work here for me createDialog Lock_verts width:185 height:110 pos:[905,407] style:#(#style_titlebar, #style_sysmenu, #style_minimizebox) )