Notifications
Clear all
[Closed] Get nearest spline to cursor
Dec 08, 2015 3:27 pm
I’m trying to make a simple Lazy Mouse script which would let someone easily select whatever object is nearest to the cursor without having to be directly over it.
This is the script atm. It has two issues in that it wont work on splines (as raycast completely ignores them), and after an object is selected max will automatically de-select it once the left mouse button is released.
fn lazySelect_fn = (
cursPos = #()
cursPos[1] = try((intersectRayScene (mapScreenToWorldRay mouse.pos))[1][1])catch() --center
cursPos[2] = try((intersectRayScene (mapScreenToWorldRay (mouse.pos + [0,-25,0])))[1][1])catch() --top
cursPos[3] = try((intersectRayScene (mapScreenToWorldRay (mouse.pos + [0,25,0])))[1][1])catch() --bottom
cursPos[4] = try((intersectRayScene (mapScreenToWorldRay (mouse.pos + [-25,0,0])))[1][1])catch() --left
cursPos[5] = try((intersectRayScene (mapScreenToWorldRay (mouse.pos + [25,0,0])))[1][1])catch() --right
mahMouse = (mouse.buttonStates as array)[1] as string
for i in cursPos do (
if i != undefined and mahMouse != "1" do ( --shows what will be selected
gw.setTransform (Matrix3 1)
gw.text (i.pos) "O" color:Yellow
gw.UpdateScreen()
exit
)
if i != undefined and mahMouse == "1" do ( --selects
select i
exit
)
)
)
if vpLazySelState == undefined do (global vpLazySelState = "Off")
if (vpLazySelState == "Off") then (registerRedrawViewsCallback lazySelect_fn ; vpLazySelState = "On")
else (UnregisterRedrawViewsCallback lazySelect_fn ; vpLazySelState = "Off")
Any ideas?
1 Reply
Dec 08, 2015 3:27 pm
Turn On the SNAP, set Edge/Segment snap type active and get the snaped node.
Then turn Off the Snap.