Notifications
Clear all

[Closed] help Running this script*does not*display*the numerical

Iwrote a simplescriptis to measure thedistancebut does not showthe results of running.Alwaysremind meUnknownproperty:“text”inundefined

:toconvert:0 totype:*-UnablePoint3

Below isthe script,well intentioned people want tohelpme solve the problem

fn cjuli =

(

*rollout frmmain “cl” width:100 height:140

*(

  • editText Text_zong “D” pos:[5,10] width:65 height:20

  • editText Text_x “X” pos:[5,35] width:65 height:20

  • editText Text_y “Y” pos:[5,60] width:65 height:20

  • editText Text_z “Z” pos:[5,85] width:65 height:20

  • button btn_measure “Dis” pos:[5,115] width:100 height:24

  • on btn_measure pressed do

  • (

  • *local pot1

  • *local pot2

  • *local dist

  • *local dist_x

  • *local dist_y

  • *local dist_z

  • *pot1=pickpoint snap:#3d

  • *if pot1==#escape or pot1==#rightClick then

  • *(

    • return ok
  • *)

  • *pot2=pickpoint snap:#3d rubberband:pot1

  • *if pot2==#escape or pot2==#rightClick then

  • *(

    • return ok
  • *)

  • *dist=distance pot2 pot1

  • *dist_x=abs(pot2.x-pot1.x)

  • *dist_y=abs(pot2.y-pot1.y)

  • *dist_z=abs(pot2.z-pot1.z)

  • *Text_zong.text=dist as string

  • *Text_x.text=dist_x as string

  • *Text_y.text=dist_y as string

  • *Text_z.text=dist_z as string

  • )

  • on frmmain rbuttonup mousehitpoint do destroydialog frmmain

    • local mouseIsDown = false,thePos = [0,0]
    • *on frmmain lbuttondown pos do
              • (mouseIsDown = true ; thePos = pos)
              • on frmmain lbuttonup pos do
              • mouseIsDown = false
              • on frmmain mousemove pos do if mouseIsDown do
              • setDialogPos frmmain (mouse.screenpos – thePos)

*)

*createdialog frmmain pos:[10,470] style:#()

)

pot1=pickpoint snap:#3d

  • *if pot1==#escape or pot1==#rightClick then

  • *(

    • return ok
  • *)

  • *pot2=pickpoint snap:#3d rubberband:pot1

  • *if pot2==#escape or pot2==#rightClick then

  • *(

    • return ok
  • *)

  • *dist=distance pot2 pot1

  • *dist_x=abs(pot2.x-pot1.x)

  • *dist_y=abs(pot2.y-pot1.y)

  • *dist_z=abs(pot2.z-pot1.z)

  • *Text_zong.text=dist as string

  • *Text_x.text=dist_x as string

  • *Text_y.text=dist_y as string

  • *Text_z.text=dist_z as string

**

cjuli()

5 Replies

disply problems,l upload the script

A quick test and just removing the last part of the script (outside the function) solve it…

Don’t you understand what I mean, I mean, after running the script, the input points, measurement results are shown in the dialog box

help me please

let’s try this :

(-- start script	
 	
 	global frmmain
 	try (destroydialog frmmain)catch()
 
 	fn cjuli =
 	(
 		rollout frmmain "cl" width:100 height:140
 		(
 			
 			editText Text_zong "D" width:65 height:20 pos:[5,10]
 			editText Text_x "X" width:65 height:20 pos:[5,35]
 			editText Text_y "Y" width:65 height:20 pos:[5,60]
 			editText Text_z "Z" width:65 height:20 pos:[5,85]
 			button btn_measure "Distance" width:80 height:24
 		
 			on btn_measure pressed do
 			(
 				pp()
 			)			
 			
 			on frmmain rbuttonup mousehitpoint do destroydialog frmmain
 		
 			local mouseIsDown = false,
 					thePos = [0,0]
 			
 			on frmmain lbuttondown pos do
 				(mouseIsDown = true ; thePos = pos)
 			on frmmain lbuttonup pos do
 				mouseIsDown = false
 			on frmmain mousemove pos do if mouseIsDown do
 				setDialogPos frmmain (mouse.screenpos - thePos)
 			
 		)--end rollout
 		
 		createdialog frmmain style:#() --pos:[10,470]
 	)--end fn
 
 	fn calculate pot1 pot2 = (
 		
 		dist=distance pot2 pot1
 		dist_x=abs(pot2.x-pot1.x)
 		dist_y=abs(pot2.y-pot1.y)
 		dist_z=abs(pot2.z-pot1.z)
 
 
 		frmmain.Text_zong.text=dist as string
 		frmmain.Text_x.text=dist_x as string
 		frmmain.Text_y.text=dist_y as string
 		frmmain.Text_z.text=dist_z as string
 	)--end fn
 
 	fn pp = (
 		
 		snapMode.active = true	-- set snap active
 		snapMode.type = #3d		-- set snap type
 
 		local p1 = pickpoint snap:#3d
 		/*
 		case of
 		(
 			(p1 == undefined): -- user pressed escape
 				print p1
 			(p1 == #rightClick): -- user clicked RMB
 				print "RMB"
 			(classOf p1 == Point3): -- user entered a point
 				print p1
 		)
 		*/
 		--print p1
 		
 		local p2 = pickpoint snap:#3d rubberband:p1		
 		--print p2
 				
 		calculate p1 p2
 
 	)--end fn
 	
 	
 	cjuli()
 
 
 )-- end script