ScriptSpot

Forum topic · Scripts Wanted

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

By cuatcside · 2022-12-14

Description

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 (4)

With a rollout: ( global

miauu · 2022-12-15

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 · 2022-12-16

Thanks.

cuatcside · 2022-12-16

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.

miauu · 2022-12-15

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])