Hello people!
Does anyone know why the callback script with
#viewportChange didn't run the callback when the distance < 1000? It's fine with rotating the viewport on any distance, but it's not the same case with zoom in/out.
Might be a little bit hard to explain with word, but here is the script that I got and you can see on the listener what I mean when you run the script;
(
callbacks.removeScripts #viewportChange id:#vpUpdate
global printDistance
fn getViewDirectionRay =
(
local
coordSysTM = Inverse(getViewTM()),
viewDir = -coordSysTM.row3,
viewPt = coordSysTM.row4
return ray viewPt viewDir
)
fn printDistance =
(
eyeRay = getViewDirectionRay()
vpPosX = eyeRay.pos[1]
vpPosY = eyeRay.pos[2]
vpPosZ = eyeRay.pos[3]
vpDistanceToZero = sqrt (((sqrt ((vpPosX ^2) + (vpPosY^2)))^2) + (vpPosZ^2))
print vpDistanceToZero
)
callbacks.addScript #viewportChange "printDistance()" id:#vpUpdate
)
.. if anyone have a better suggestion or thought, please do share

Replies
( callbacks.removeScripts #viewportChange id:#vpUpdate global printDistance fn getViewDirectionRay = ( print "-----------------------" coordSysTM = Inverse(getViewTM()) format "coordSysTM: % \n" coordSysTM viewDir = -coordSysTM.row3 viewPt = coordSysTM.row4 format "viewDir: % viewPt:%\n" viewDir viewPt format "ray: % \n" (ray viewPt viewDir) -- ray viewPt viewDir ) fn printDistance = ( eyeRay = getViewDirectionRay() format "eyeRay: % \n" eyeRay vpPosX = eyeRay.pos[1] vpPosY = eyeRay.pos[2] vpPosZ = eyeRay.pos[3] vpDistanceToZero = sqrt (((sqrt ((vpPosX ^2) + (vpPosY^2)))^2) + (vpPosZ^2)) format "dist: % \n" vpDistanceToZero ) callbacks.addScript #viewportChange "printDistance()" id:#vpUpdate )to check the value of each variable.( global test fn test = print "test" callbacks.removeScripts #viewportChange id:#vpUpdate callbacks.addScript #viewportChange "test()" id:#vpUpdate ).. and it is still showing weird behavior (unable to call the script with zoom in/ out on < 1000 distance from the world center)...I run out of idea to try to fix this if the problem lies on Maxscript's inconsistency...I'll appreciate if anyone else able to try and report back the result here. Thanks!The worst method to try - reinstlal 3dsMax.
Hey miauu, what about (un)registerRedrawViewsCallback? do you have experience with it?
From a simple test that I did, it seems like slow down max quite noticable..
It call the script anytime the viewport redraw including editing the object, but #viewportChange only call the script when the viewport rotate/zoom (above 1000).
Edit: Watch this video to see that your script works.
Hey! thats the behavior that I wanted!hahaha..so weird that it's not working right here..
Thanks for the viedo miauu, atleast I know it's not a bug or something that can't be "fixed".
Just for information;
3ds Max 2014 x64
Nitrous driver (tried on Legacy Direct3D as well)
Centimeter unit setup/ system unit setup
Windows 7
Hmm..I wish there's someone with a fresh max install to try it out..
It's not just about activating the grid helper, even when the non-active grid helper is on the scene, it's still printed only above 1000...