Notifications
Clear all

[Closed] script controller distance help

Hello,

I am trying to make script controller that prints the distance of two help pointer into the listener. But i am not able to make it work. So i now have the basics for it, i think.
Could somebody give me some advice on how to make it work correct. I checked the maxscript helpfile and trid those examples and tried to adapt those, but no results.

start_pos = $point001.pos
eind_pos = $point002.pos

ctrl = position_script()
ctrl.script = “distance start_pos eind_pos”

3 Replies

Try

distance $point001 $point002

without .pos

Hi scrimski,

unfortunate i get a script controller exception, “unable to convert 76.7045 to type:Point3”

even when i just hardcode it like:

 ctrl = position_script() 
ctrl.script = "distance $point001 $point002"

it doenst work.

if you’ve added this controller to a position track, it will be expecting the point3 value for the end after you’ve printed the data.

ctrl.script = "distance $point001 $point002
[0,0,0]"

on approach is to store the point as nodes to make it a little more robust :

(
p1 = point name:"point001" box:true wirecolor:red pos:[50,0,0]
p2 = point name:"point002" box:true wirecolor:yellow pos:[-50,0,0]
pm	= point name:"pointMaster" box:false cross:true wirecolor:green
	
scr = position_script()
scr.addnode "p1" p1
scr.addnode "p2" p2
scr.script = "if isvalidnode p1 and isvalidnode p2 then format \"Distance p1-p2:%\
\" (distance p1 p2)
[0,0,0]"
pm.position.controller = scr	
)