Simple Script to select 2 points and output the distance in a label

Hi,
I need a very simple script rollout that has 2 buttons and one label.
By clicking on the first button one can pick one single point and by pressing second button the next point and after selecting both points the distance between the 2 points will be shown in a label in the rollout.
I would really appreciate your help.
Thanks.

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
miauu's picture

With a rollout: ( global

With a rollout:

(
	global rol_showDistance
	try(destroyDialog rol_showDistance)catch()
	rollout rol_showDistance "Show Distance"
	(
		button btn_showDistance "Show Distance" width:140 align:#center
		edittext et_dist "" text:"" align:#center
 
		on btn_showDistance pressed do
		(
			if selection.count == 2 then
			(
				et_dist.text = units.formatValue (distance selection[1].pos selection[2].pos)
			)
			else
				messagebox "Please, select only 2 objects" title:""
		)
	)
	createdialog rol_showDistance 
)
cuatcside's picture

This is what I needed. I just

This is what I needed. I just need to figure out how to create 2 buttons one to select the first object and second to select the 2nd object.
I appreciate it.
Thanks.

cuatcside's picture

Thanks.

Thanks.

miauu's picture

Not exactly what you

Not exactly what you need.
Select 2 objects(points, etc.) and run this. In the maxscript istener you can see tie distance between the selected objects.

if selection.count == 2 do format "Distance: " % \n" (distance selection[1] selection[2])

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.