I missed that this thread had slipped to page two, so I apologize for the late reply.
Roxol, wow I don’t know where you dug up “timeStamp()” because I can’t find any reference to it in the maxscript help files but that solves a lot of the issues I was having with defining the time, like Rob pointed out.
Rob, when the script is run once it is added to the “usermacros” folder which runs when max starts. Also thank you for introducing me to structs that is going to be very useful going forward!
What I ended up trying to do on my own was define the min and sec, then convert that over to seconds and compare that to the last time. But timestamp() simplifies that process a lot and makes it a lot less buggy because it suffered from the same problem but only when a min went by. I was going to try and expand it to include hours also but tapping the key again was easier than digging back into it, so I hadn’t done that yet heh…
So yea here is the final script I’m using:
macroscript ToggleMove
Category:" VigTools"
toolTip:"ToggleMove (Q)*"
(--MOVE
max move--switch to move mode first
global lastClickedMove-- define lastClickedMove, but we don't need to assign it to anything.
fn RefCoordCycle_LV = (--Cycles the RefCoordsys between Local & View
if getRefCoordSys() == #local then (
toolmode.coordsys #view
)
else (
toolmode.coordsys #local
)
)
fn RefCoordCycle_LVS = (--Cycles the RefCoordsys between Local, View &Screen
if getRefCoordSys() == #screen then (
toolmode.coordsys #view
)
else (
if getRefCoordSys() == #hybrid then (
toolmode.coordsys #local
)
else (
toolmode.coordsys #screen
)
)
)
fn checklastClickedMove = (
local thisClickedMove = timeStamp()
if lastClickedMove != undefined then (
if (thisClickedMove - lastClickedMove) < 500 do (--adjust this value to shorten or lengthen wait time
max move
RefCoordCycle_LV()--Switch this to _LVS to cycle between Local, View & Screen
)
print (getRefCoordSys() as string)
lastClickedMove = thisClickedMove
)
else (--switch gizmo to move, ignore pivot setting, update "lastClickedMove"
max move
print (getRefCoordSys() as string)
lastClickedMove = timeStamp()
)
OK
)
checklastClickedMove()
)
macroscript ToggleRot
Category:" VigTools"
toolTip:"ToggleRot (W)*"
(--ROTATION
max rotate --switch to rotate mode first
global lastClickedRot-- define lastClickedRot, but we don't need to assign it to anything.
fn RefCoordCycle_LV = (--Cycles the RefCoordsys between Local & View
if getRefCoordSys() == #local then (
toolmode.coordsys #view
)
else (
toolmode.coordsys #local
)
)
fn RefCoordCycle_LVS = (--Cycles the RefCoordsys between Local, View &Screen
if getRefCoordSys() == #screen then (
toolmode.coordsys #view
)
else (
if getRefCoordSys() == #hybrid then (
toolmode.coordsys #local
)
else (
toolmode.coordsys #screen
)
)
)
fn checklastClickedRot = (
local thisClickedRot = timeStamp()
if lastClickedRot != undefined then (
if (thisClickedRot - lastClickedRot) < 500 do (--adjust this value to shorten or lengthen wait time
max rotate
RefCoordCycle_LV()--Switch this to _LVS to cycle between Local, View & Screen
)
print (getRefCoordSys() as string)
lastClickedRot = thisClickedRot
)
else (--switch gizmo to Rot, ignore pivot setting, update "lastClickedRot"
max rotate
print (getRefCoordSys() as string)
lastClickedRot = timeStamp()
)
OK
)
checklastClickedRot()
)
macroscript ToggleScale
Category:" VigTools"
toolTip:"ToggleScale (E)*"
(--SCALE
max scale--switch to scale mode first
-- define lastClickedScale, but we don't need to assign it to anything.
global lastClickedScale
fn RefCoordCycle_LV = (--Cycles the RefCoordsys between Local & View
if getRefCoordSys() == #local then (
toolmode.coordsys #view
)
else (
toolmode.coordsys #local
)
)
fn RefCoordCycle_LVS = (--Cycles the RefCoordsys between Local, View &Screen
if getRefCoordSys() == #screen then (
toolmode.coordsys #view
)
else (
if getRefCoordSys() == #hybrid then (
toolmode.coordsys #local
)
else (
toolmode.coordsys #screen
)
)
)
fn checklastClickedScale = (
local thisClickedScale = timeStamp()
if lastClickedScale != undefined then (
if (thisClickedScale - lastClickedScale) < 500 do (--adjust this value to shorten or lengthen wait time
max scale
RefCoordCycle_LV()--Switch this to _LVS to cycle between Local, View & Screen
)
print (getRefCoordSys() as string)
lastClickedScale = thisClickedScale
)
else (--switch gizmo to Scale, ignore pivot setting, update "lastClickedScale"
max Scale
print (getRefCoordSys() as string)
lastClickedScale = timeStamp()
)
OK
)
checklastClickedScale()
)
It’s one .ms script file with 3 macroscripts included, Move Rotation and Scale. There is a lot similar code but had to be dupliated for each macro. I think I could simplify if I started housing bits of code in external files and called those external functions from within the macros but that’s a challenge for another day and makes it kind of hard to trouble shoot because when an error pops up it just points to another file and doesn’t tell me what line in that file…
At this point its working great, so I’m going to leave well enough alone! Thanks guys! You taught me a lot of great stuff!