
! script name: turbopost.d/new_zero

!A
!A NAME:
!A
!A 	NEWZERO
!A
!A DESCRIPTION:
!A
!A 	This script uses the workplane associated with an entity to set
!A	the coordinate zero by outputing the values to the command file.
!A
!B INSTRUCTIONS:
!B
!B 	PICK ELEMENT FOR NEW ORIGIN: pick the element to be used as the new
!B	origin.

stat=ChangeLabelStr("ScriptNameStatus","Function: new_zero ")

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

DeActivateUndo
Stat=MakeActiveCurr

Stat=CurrActionName(Command$)
Command_type=CurrActionTyp

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

X=XPointValue(Pt)
Y=YPointValue(Pt)
Z=ZPointValue(Pt)
Stat=DeleteEntity(Pt)

A$="ASSIGN: Xorgshift= "&VAL$(X)&"; Yorgshift= "&VAL$(Y)&"; Zorgshift= "&VAL$(Z)&";"
Stat=OutputCmdBuff(A$,0)
Stat=OutputCmdBuff(Command$,0)

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

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