
! script name: zplanes.d/workplane
! topic: define workplane using reference point and angles

!A
!A NAME:
!A
!A 	Input Workplane
!A
!A DESCRIPTION:
!A
!A 	This script allows a new workplane to be defined using a reference
!A 	point and angles for X, Y, and Z.  The resultant rotation is calculated
!A 	first by rotating about the Y axis, then the X axis, and finally the
!A 	Z axis.
!A
!B INSTRUCTIONS:
!B
!B 	REFERENCE POINT ABS X,Y,Z: Enter the X,Y,Z coordinates of the reference
!B 		point for the new workplane.  NOTE: See XYZ INPUT OPTIONS.
!B
!B 	X ANGLE: Enter the X angle to be used for the rotation of workplane
!B 		about X axis.
!B
!B 	Y ANGLE: Enter the Y angle to be used for the rotation of workplane
!B 		about Y axis.
!B
!B 	Z ANGLE: Enter the Z angle to be used for the rotation of workplane
!B 		about Z axis.
!B
!# see also - points.d/xyzinput.hlp

stat=ChangeLabelStr("ScriptNameStatus","Function: input workplane ")

DIM Answer$[256]
DIM Destination$[256]
DEG

StdWorkplane
stat= SetInputFormat("n4","")

Pt=XyzInput("REFERENCE POINT ",WsXyzInput)
IF (ExitScript(Destination$)) THEN Leave

stat= SetInputFormat("n4=","")
Stat= SetEqualsValue(0)
Xangle=GetValue("X ANGLE",Answer$)
IF (ExitScript(Destination$)) THEN Leave

stat= SetInputFormat("n4=","")
Stat= SetEqualsValue(0)
Yangle=GetValue("Y ANGLE",Answer$)
IF (ExitScript(Destination$)) THEN Leave

stat= SetInputFormat("n4=","")
Stat= SetEqualsValue(0)
Zangle=GetValue("Z ANGLE",Answer$)
IF (ExitScript(Destination$)) THEN Leave

T1=AngleTransform(Pt,Xangle,Yangle,Zangle)

Stat=SetWorkplane(T1)
IF IsRulerOn THEN PlotAll

WplaneEnt= FindNamedVar("current work area",123456)
IF ValidGeometry(WplaneEnt) THEN Stat= DeleteEntity(WplaneEnt)

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