
! script name: turbopost.d/new_zero2

!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
Work=CurrentWorkplane

Pick_loop:!
Element=PickEntity("PICK ELEMENT")
IF (ExitScript(Destination$)) THEN Leave
IF (NOT ValidGeometry(Element)) THEN Pick_loop

Trans=GetTransform(Element)
IF NOT ValidGeometry(Trans) THEN
	Pz= PointXYZ(0,0,0)
	Trans= AngleTransform(Pz,0,0,0)
	stat= DeleteEntity(Pz)
END IF


Stat=OutputCmdBuff(A$,0)
Stat=OutputCmdBuff(Command$,0)

IF (ValidGeometry(Work)) THEN
	Stat=SetWorkplane(Work)
ELSE
	StdWorkplane
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
