
! script name: turbopost.d/cmmzhole

!A
!A NAME:
!A
!A 	MANUAL Z HOLES
!A
!A DESCRIPTION:
!A
!A 	This script allows the user to input the X,Y,Z point coordinates in
!A 	TurboPost without creating geometry, to be used by the command file.
!A 	This script may be accessed by typing "MZ" when the "Manual" option is
!A 	one of the choices.  The picktypes, which are set in the users command
!A 	file for a particular post, are "Z" and "z".  "Z" allows multiple XYZ
!A 	coordinate input, and "z" allows only a single XYZ coordinate to be
!A 	input.
!A
!B INSTRUCTIONS:
!B
!B 	INPUT ABS X,Y,Z: Enter the X,Y,Z coordinates of the point to be used
!B 		by the command file.  To return to the command menu, enter the
!B 		coordinates of the last point twice.
!B 		NOTE: See XYZ INPUT OPTIONS.
!B
!# see also - points.d/xyzinput.hlp

stat=ChangeLabelStr("ScriptNameStatus","Function: manual z holes ")

DIM Destination$[256]
DIM Answer$[256]
DIM Command$[256]
DIM A$[256]


DeActivateUndo
Delta=0.001
First=1
Pick_loop:!

Stat=MakeActiveCurr

Stat=CurrActionName(Command$)
Command_type=CurrActionTyp

Stat=SetPickMask(WsPickAll)
Stat=SetInputFormat("a6",",P,MZ,S,N,CANCEL,")
Pt=XyzInput("INPUT",WsXyzInput)
IF (ExitScript(Destination$)) THEN Leave

SELECT Answer$
CASE "CANCEL"
	LOAD "turbopost.d/turbocmd"
CASE "P","p"
	GOTO New_command
CASE "S","s"
	  LOAD "turbopost.d/seqholes"
CASE "M","m"
	  LOAD "turbopost.d/manualhole"
CASE "MZ","mz"
	  LOAD "turbopost.d/cmmzhole"
END SELECT

Picked_a_pt= ValidGeometry(LastPickEnt)
Stat=OutputCmdBuff("ASSIGN: Picked_a_pt="&VAL$(Picked_a_pt)&";",0)

X=XPointValue(Pt)
Y=YPointValue(Pt)
Z=ZPointValue(Pt)
Stat=DeleteEntity(Pt)
IF NOT First THEN
	Dist=ABS(X-Xr)+ABS(Y-Yr)+ABS(Z-Zr)
	IF (Dist<Delta) THEN New_command
END IF

Xr=X
Yr=Y
Zr=Z
First=0


IF POS(Command$,"MACRO:") OR POS(Command$,"TEMPLATE:") THEN
	A$="ASSIGN:"&" Xstart= "&VAL$(X)&";"&" Ystart= "&VAL$(Y)&";"&" Zstart= "&VAL$(Z)&";"
	Stat=OutputCmdBuff(A$,0)
	Stat=OutputCmdBuff(Command$,0)
ELSE
	A$="ASSIGN:"&" X= "&VAL$(X)&";"&" Y= "&VAL$(Y)&";"&" Z= "&VAL$(Z)&";"
	Stat=OutputCmdBuff(A$,0)
	Stat=OutputCmdBuff(Command$,0)
END IF

New_command:UpdateCmdFile
	Stat=SetPickMask(WsPickAll)
	Stat=SetInputFormat("n4=","")
	  LOAD "turbopost.d/turbocmd"

Leave:!
IF (NOT LEN(Destination$)) THEN
	  LOAD "typecontrol"
ELSE
	  LOAD Destination$
END IF
END
