macroScript LockKeysUtils category:"Grants" ( -- v1.2 KeyArray_keys = #() modKeyArrayIn = #() modKeyArrayOut = #() keyTest_b = #() directi = 0 selKeysAr = #() fn getAnimProp obj = ( local keyTest if obj.numSubs > 0 then ( for i = 1 to obj.numSubs do ( getAnimProp obj[i] ) ) else ( if (keyTest = obj.keys) != undefined and keyTest.count > 0 do ( for k in 1 to keyTest.count do ( append KeyArray_keys keytest[k] ) ) ) ) fn getSelectedKeys = ( KeyArray_keys = #() for o in selection do getAnimProp o ) rollout lockkeys "Modify Existing keys (any track)" ( fn setSelectedKeysfwd = ( modKeyArrayIn = #() modKeyArrayOut = #() for i in 1 to KeyArray_keys.count do ( try ( if KeyArray_keys[i].selected then ( try KeyArray_keys[i].outTangentType = #linear catch() append modKeyArrayIn KeyArray_keys[i] try KeyArray_keys[i+1].inTangentType = #linear catch() append modKeyArrayOut KeyArray_keys[i+1] ) ) catch () ) ) fn setSelectedKeysbck = ( modKeyArrayIn = #() modKeyArrayOut = #() for i in 1 to KeyArray_keys.count do ( try ( if KeyArray_keys[i].selected then ( try KeyArray_keys[i].inTangentType = #linear catch() append modKeyArrayOut KeyArray_keys[i] try KeyArray_keys[i-1].outTangentType = #linear catch append modKeyArrayIn KeyArray_keys[i-1] ) ) catch () ) ) fn setInOut = ( if lockkeys.opsm.checked and (lockkeys.opsmcus.checked == false) then ( for i in 1 to modKeyArrayIn.count do ( try (modKeyArrayIn[i].inTangentType = #smooth) catch() ) for i in 1 to modKeyArrayOut.count do ( try (modKeyArrayOut[i].outTangentType = #smooth) catch() ) ) if lockkeys.opsmcus.checked and (lockkeys.opsm.checked == false) then ( for i in 1 to modKeyArrayIn.count do ( try (modKeyArrayIn[i].inTangentType = #custom) catch() ) for i in 1 to modKeyArrayOut.count do ( try (modKeyArrayOut[i].outTangentType = #custom) catch() ) ) if lockkeys.opsmcus.checked and lockkeys.opsm.checked then ( for i in 1 to modKeyArrayIn.count do ( try (modKeyArrayIn[i].inTangentType = #custom; modKeyArrayIn[i].inTangent = -modKeyArrayIn[i].outTangent) catch() ) for i in 1 to modKeyArrayOut.count do ( try (modKeyArrayOut[i].outTangentType = #custom; modKeyArrayOut[i].outTangent = -modKeyArrayOut[i].inTangent) catch() ) ) ) fn setSameVal = ( try ( if directi == 0 then ( for i in 1 to modKeyArrayIn.count do modKeyArrayOut[i].value = modKeyArrayIn[i].value ) if directi == 1 then ( for i in 1 to modKeyArrayOut.count do modKeyArrayIn[i].value = modKeyArrayOut[i].value ) ) catch() ) label war "Selected keys in selected objects only" button lck "Lock selected Forwards" width:192 button lckbk "Lock selected Backwards" width:192 checkbox smval "Next/Prev key to same value" checked:true checkbox opsm "Set outer to smooth" checked:true checkbox opsmcus "Set outer to custom" checked:false button lcksmrt "Lock all keys that have same values" width:192 offset:[-1,0] button desel "Deselect all keys in selected objects" width:192 offset:[-2,0] on lck pressed do ( directi = 0 getSelectedKeys(); setSelectedKeysfwd() if smval.checked then setSameVal() redrawViews(); setInOut() -- need this else retrieving tangenttype does not give correct value first time - anyone know the correct update I should use? ) on lckbk pressed do ( directi = 1 getSelectedKeys(); setSelectedKeysbck() if smval.checked then setSameVal() redrawViews(); setInOut() ) on desel pressed do deselectkeys $selection on lcksmrt pressed do ( getSelectedKeys() selKeys = #() modKeyArrayIn = #() modKeyArrayOut = #() for i in 1 to keyArray_keys.count do ( if keyArray_keys[i].selected then append selKeys keyArray_keys[i] ) for i in 1 to selKeys.count do ( try ( if (selKeys[i].time < selKeys[i+1].time) and (selKeys[i].value == selKeys[i+1].value) then -- still allows rare case when keys not intended modify. How to fix? ( try selKeys[i].outTangentType = #linear catch() append modKeyArrayIn selKeys[i] try selKeys[i+1].inTangentType = #linear catch() append modKeyArrayOut selKeys[i+1] ) ) catch() ) redrawViews(); setInOut() ) ) rollout lock_setting "Create Lock Keys" ( label war2 "Operates on ALL selected objects" button poslck "Create Pos Lock" align:#left width:110 across:2 checkbox ex "X" checked:true align:#right offset:[0,3] button rotlck "Create Rot Lock" align:#left width:110 across:2 checkbox why "Y" checked:true align:#right offset:[0,3] button scllck "Create Scale Lock" align:#left width:110 across:2 checkbox zed "Z" checked:true align:#right offset:[0,3] on poslck pressed do ( try ( for i in 1 to selection.count do ( If (Classof Selection[i].pos.controller) == Position_xyz then ( if ex.checked then createlockkey selection[i].pos.x_Position.controller currentTime 0 if why.checked then createlockkey selection[i].pos.y_Position.controller currentTime 0 if zed.checked then createlockkey selection[i].pos.z_Position.controller currentTime 0 ) If (Classof Selection[i].pos.controller) == Position_list then ( try ( if ex.checked then createlockKey selection[i].pos.controller[ListCtrl.GetActive Selection[i].pos.controller].X_Position.controller currentTime 0 if why.checked then createlockKey selection[i].pos.controller[ListCtrl.GetActive Selection[i].pos.controller].y_Position.controller currentTime 0 if zed.checked then createlockKey selection[i].pos.controller[ListCtrl.GetActive Selection[i].pos.controller].z_Position.controller currentTime 0 ) catch() createlockkey selection[i].pos.controller[ListCtrl.GetActive Selection[i].pos.controller] currentTime 0 ) createlockkey selection[i].pos.controller currentTime 0 ) ) catch() ) on rotlck pressed do ( try ( for i in 1 to selection.count do ( createlockkey selection[i].rotation.controller currentTime 0 If (Classof Selection[i].rotation.controller) == Euler_xyz then ( if ex.checked then createlockkey selection[i].rotation.controller.x_rotation.controller currentTime 0 if why.checked then createlockkey selection[i].rotation.controller.y_rotation.controller currentTime 0 if zed.checked then createlockkey selection[i].rotation.controller.z_rotation.controller currentTime 0 ) If (Classof Selection[i].rotation.controller) == Local_Euler_xyz then ( if ex.checked then createlockkey selection[i].rotation.controller.local_x_rotation.controller currentTime 0 if why.checked then createlockkey selection[i].rotation.controller.local_y_rotation.controller currentTime 0 if zed.checked then createlockkey selection[i].rotation.controller.local_z_rotation.controller currentTime 0 ) createlockkey selection[i].rotation.controller currentTime 0 If (Classof Selection[i].rotation.controller) == Rotation_list then ( try ( if ex.checked then createlockKey selection[i].rotation.controller[ListCtrl.GetActive Selection[i].rotation.controller].X_rotation.controller currentTime 0 if why.checked then createlockKey selection[i].rotation.controller[ListCtrl.GetActive Selection[i].rotation.controller].y_rotation.controller currentTime 0 if zed.checked then createlockKey selection[i].rotation.controller[ListCtrl.GetActive Selection[i].rotation.controller].z_rotation.controller currentTime 0 ) catch() try ( if ex.checked then createlockKey selection[i].rotation.controller[ListCtrl.GetActive Selection[i].rotation.controller].local_X_rotation.controller currentTime 0 if why.checked then createlockKey selection[i].rotation.controller[ListCtrl.GetActive Selection[i].rotation.controller].local_y_rotation.controller currentTime 0 if zed.checked then createlockKey selection[i].rotation.controller[ListCtrl.GetActive Selection[i].rotation.controller].local_z_rotation.controller currentTime 0 ) catch() createlockKey selection[i].rotation.controller[ListCtrl.GetActive Selection[i].rotation.controller] currentTime 0 ) ) ) catch() ) on scllck pressed do ( try ( for i in 1 to selection.count do ( If (Classof Selection[i].scale.controller) == scalexyz then ( if ex.checked then createlockkey selection[i].scale.x_scale.controller currentTime 0 if why.checked then createlockkey selection[i].scale.y_scale.controller currentTime 0 if zed.checked then createlockkey selection[i].scale.z_scale.controller currentTime 0 ) If (Classof Selection[i].scale.controller) == Scale_list then ( try ( if ex.checked then createlockKey selection[i].scale.controller[ListCtrl.GetActive Selection[i].scale.controller].X_scale.controller currentTime 0 if why.checked then createlockKey selection[i].scale.controller[ListCtrl.GetActive Selection[i].scale.controller].y_scale.controller currentTime 0 if zed.checked then createlockKey selection[i].scale.controller[ListCtrl.GetActive Selection[i].scale.controller].z_scale.controller currentTime 0 ) catch() createlockkey selection[i].scale.controller[ListCtrl.GetActive Selection[i].scale.controller] currentTime 0 ) createlockkey selection[i].scale.controller currentTime 0 ) ) catch() ) ) -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -- end if lk != undefined then closerolloutfloater lk lk = newRolloutFloater "Lock Keys Utils" 230 378 addRollout lockkeys lk addRollout lock_setting lk )