------------------------------------------------------------------------------ -- move by keyboard.ms -- By Sergo Pogosyan (www.sergepogosyan.com, contact@sergepogosyan.com) -- v 0.9 -- Created On: 2008-09-10 -- tested using Max 9.0, 2008, 2009 ------------------------------------------------------------------------------- -- Description: -- macroscripts for moving polygons and objects by keyboard. -- supports Edit Poly modifier's polygons, Editable Poly's polygons and Editable Mesh's polygons. -- In any other selection or in base object level whole object is moving in current coordinate system. ------------------------------------------------------------------------------- -- Installing and usage: -- Install macroscripts by running this file and assign shortcut keys to "MovePositiveByKeyboard" and "MoveNegativeByKeyboard" scripts. -- Select objects or polygons(only) in EditablePoly/EditPoly/EditableMesh subobjects and press assigned keys to move objects/polygons forth or back on the selected axe. -- Axis could be selected by the Axis Contstraints toolbar or by the shortcuts. -- Only one axe should be selected. ------------------------------------------------------------------------------- -- TO DO list: -- Major features -- 1. Add user refernce coordinate system support -- 2. Add screen refernce coordinate system support -- 3. Add automatic keys assignement. -- Minor features ------------------------------------------------------------------------------- -- history -- 2011-06-01: Object, Grid and Working Pivot coordsys are added to object mode -- 2008-10-10: step size changing through global variable and separate script added -- 2008-09-24: Editable Mesh support added -- 2008-09-23: Editable Poly support added -- 2008-09-22: EditPoly modifier support added ------------------------------------------------------------------------------- macroScript Set_MoveByKeyboard_Step category:"Sergo Pogosyan" toolTip:"Set step size for MoveByKeyboard scripts" buttonText:"Set step size" ( rollout SetStepDialog "Set Step Size" ( global MoveByKeyboard_Step = 1.0 local old_step = 1.0 group "Step Size" ( spinner step_spinner "Step Size" align:#center range:[-10000,10000,0] button cancel_but "Cancel" width:60 across:2 button ok_but "Ok" width:60 across:1 ) on SetStepDialog open do ( if MoveByKeyboard_Step != undefined then --check if global variable exist ( step_spinner.value = MoveByKeyboard_Step old_step = MoveByKeyboard_Step ) else ( old_step = 1.0 print "Global Variable MoveByKeyboard_Step doesn't exist" ) ) on step_spinner changed val do ( if MoveByKeyboard_Step != undefined then --check if global variable exist ( old_step = MoveByKeyboard_Step --store step size for resoration on canceling MoveByKeyboard_Step = val ) else print "Global Variable MoveByKeyboard_Step doesn't exist" ) on cancel_but pressed do --on cancel button return selection to initial state ( MoveByKeyboard_Step = old_step --restore old step value destroyDialog SetStepDialog --and close dialogbox ) on ok_but pressed do ( destroyDialog SetStepDialog --if ok pressed just close dialog box ) on SetStepDialog close do ( ) ) createDialog SetStepDialog modal:false escapeEnable:true ) macroScript MovePositiveByKeyboard category:"Sergo Pogosyan" toolTip:"Move objects forward with keyboard by constant steps on the active axis" buttonText:"Move objects" -- Icon:#("sergoIcons",100) ( step = 0.0 --step to increment position at active axis on execute do ( --step to increment position at active axis if MoveByKeyboard_Step == undefined then --check if global variable exist step = 1.0 else step = MoveByKeyboard_Step --firstly, check subobject level, if selection in subobject level then move subobject objects_to_move = $selection as array --for subobject level affect all objects in selection --Editable Mesh if modPanel.getCurrentObject() as string == "Editable Mesh" and subobjectlevel == 4 then --check modifier and level number ( activeAxis = case toolmode.axisConstraints of ( #x: sergo_moveEditableMesh objects_to_move[1] ([step, 0, 0]) #y: sergo_moveEditableMesh objects_to_move[1] ([0, step, 0]) #z: sergo_moveEditableMesh objects_to_move[1] ([0, 0, step]) default: messageBox "Activate one axis!" title:"macroscript" ) ) --Editable Poly else if modPanel.getCurrentObject() as string == "Editable Poly" and subobjectlevel == 4 then --check modifier and level number ( activeAxis = case toolmode.axisConstraints of ( #x: sergo_moveEditablePoly objects_to_move[1] ([step, 0, 0]) #y: sergo_moveEditablePoly objects_to_move[1] ([0, step, 0]) #z: sergo_moveEditablePoly objects_to_move[1] ([0, 0, step]) default: messageBox "Activate one axis!" title:"macroscript" ) ) --Edit Poly modifier else if modPanel.getCurrentObject() as string == "Edit_Poly:Edit Poly" and subobjectlevel == 4 then --check modifier and level number ( activeAxis = case toolmode.axisConstraints of ( #x: sergo_movePoly objects_to_move ([step, 0, 0]) #y: sergo_movePoly objects_to_move ([0, step, 0]) #z: sergo_movePoly objects_to_move ([0, 0, step]) default: messageBox "Activate one axis!" title:"macroscript" ) ) --Objects itself else --this is the case if subobject is not selected or if modifier is not edit poly or no modifier at all ( objects_to_move = excludeChildren selection as array refcoordsys = getRefCoordSys() if refcoordsys == #object then ( refcoordsys = (toolMode.coordSysNode) --see if coordsys is an object if refcoordsys == undefined then --if coordsys is an active Grid refcoordsys = activeGrid if refcoordsys == undefined then --if active grid is a home grid refcoordsys = #world ) else if refcoordsys == #hybrid then --refcoordsys == #world and refcoordsys != #parent and refcoordsys != #local then refcoordsys = #world else if refcoordsys == undefined then refcoordsys = WorkingPivot.getTM() --use this to move in refcoordsys mode (toolMode.coordSysNode) activeAxis = case toolmode.axisConstraints of ( #x:in coordsys refcoordsys move objects_to_move [step,0,0] #y:in coordsys refcoordsys move objects_to_move [0,step,0] #z:in coordsys refcoordsys move objects_to_move [0,0,step] default: messageBox "Activate one axis!" title:"macroscript" ) ) ) ) macroScript MoveNegativeByKeyboard category:"Sergo Pogosyan" toolTip:"Move objects backward with keyboard by constant steps on the active axe" buttonText:"Move objects" -- Icon:#("sergoIcons",100) ( step = 0 on execute do ( --step to increment position at active axis if MoveByKeyboard_Step == undefined then --check if global variable exist step = 1.0 else step = MoveByKeyboard_Step --firstly, check subobject level, if selection in subobject level then move subobject objects_to_move = $selection as array --for subobject level affect all objects in selection --Editable Mesh if modPanel.getCurrentObject() as string == "Editable Mesh" and subobjectlevel == 4 then --check modifier and level number ( activeAxis = case toolmode.axisConstraints of ( #x: sergo_moveEditableMesh objects_to_move[1] ([-step, 0, 0]) #y: sergo_moveEditableMesh objects_to_move[1] ([0, -step, 0]) #z: sergo_moveEditableMesh objects_to_move[1] ([0, 0, -step]) default: messageBox "Activate one axis!" title:"macroscript" ) ) --Editable Poly else if modPanel.getCurrentObject() as string == "Editable Poly" and subobjectlevel == 4 then --check modifier and level number ( activeAxis = case toolmode.axisConstraints of ( #x: sergo_moveEditablePoly objects_to_move[1] ([-step, 0, 0]) #y: sergo_moveEditablePoly objects_to_move[1] ([0, -step, 0]) #z: sergo_moveEditablePoly objects_to_move[1] ([0, 0, -step]) default: messageBox "Activate one axis!" title:"macroscript" ) ) --Edit Poly modifier else if modPanel.getCurrentObject() as string == "Edit_Poly:Edit Poly" and subobjectlevel == 4 then --check modifier and level number ( activeAxis = case toolmode.axisConstraints of ( #x: sergo_movePoly objects_to_move ([-step, 0, 0]) #y: sergo_movePoly objects_to_move ([0, -step, 0]) #z: sergo_movePoly objects_to_move ([0, 0, -step]) default: messageBox "Activate one axis!" title:"macroscript" ) ) --Objects itself else --this is the case if subobject is not selected or if modifier is not edit poly or no modifier at all ( objects_to_move = excludeChildren selection as array refcoordsys = getRefCoordSys() if refcoordsys == #object then ( refcoordsys = (toolMode.coordSysNode) --see if coordsys is an object if refcoordsys == undefined then --if coordsys is an active Grid refcoordsys = activeGrid if refcoordsys == undefined then --if active grid is a home grid refcoordsys = #world ) else if refcoordsys == #hybrid then --refcoordsys == #world and refcoordsys != #parent and refcoordsys != #local then refcoordsys = #world else if refcoordsys == undefined then refcoordsys = WorkingPivot.getTM() activeAxis = case toolmode.axisConstraints of ( #x:in coordsys refcoordsys move objects_to_move [-step,0,0] #y:in coordsys refcoordsys move objects_to_move [0,-step,0] #z:in coordsys refcoordsys move objects_to_move [0,0,-step] default:messageBox "Activate one axis!" title:"macroscript" ) ) ) )