
! script name: zplanes.d/plane3pts
! topic: define workplane by three unique points

!A
!A NAME:
!A
!A 	Workplane: 3 Points
!A
!A DESCRIPTION:
!A
!A 	This script allows a workplane to be defined by three unique points.
!A
!A~ image location - images/zplane3pts.jpg
!B INSTRUCTIONS:
!B
!B 	FIRST POINT ABS X,Y,Z: Enter the X,Y,Z
!B 		coordinates for the first point.
!B 		NOTE: See XYZ INPUT OPTIONS.
!B
!B 	SECOND POINT ABS X,Y,Z: Enter the X,Y,Z
!B 		coordinates for the second point.
!B
!B 	THIRD POINT ABS X,Y,Z: Enter the X,Y,Z
!B 		coordinates for the third point.
!B
!# see also - points.d/xyzinput.hlp

stat=ChangeLabelStr("ScriptNameStatus","Function: workplane: 3 points ")

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

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

P1=XyzInput("FIRST POINT",WsXyzInput)
IF (ExitScript(Destination$)) THEN Leave

P2=XyzInput("SECOND POINT",WsXyzInput)
IF (ExitScript(Destination$)) THEN Leave

P3=XyzInput("THIRD POINT",WsXyzInput)
IF (ExitScript(Destination$)) THEN Leave

T1=ThreePtTrans(P1,P2,P3)

Stat=SetWorkplane(T1)
IF IsRulerOn THEN PlotAll

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

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