
! script name: zplanes.d/zplane
! topic: define workplane parallel to XY plane at specified Z

!A
!A NAME:
!A
!A 	Z Level
!A
!A DESCRIPTION:
!A
!A 	This script makes a workplane parallel to the XY plane at the
!A 	specified Z level. Use a Z Level to construct 2D geometry at
!A	a Z coordinate other than zero. When a Z Level is established
!A	all absolute Z values input are referenced from that Z Level.
!A
!A~ image location - images/zplane.jpg
!B INSTRUCTIONS:
!B
!B 	Z LEVEL:  Enter the Z coordinate for the Z level to be established at.
!B

stat=ChangeLabelStr("ScriptNameStatus","Function: z level ")

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

StdWorkplane
stat= SetInputFormat("n4","")
Stat=SetPickReturn(WsGeometryZ)

stat= SetInputFormat("n4=","")
Zlevel=GetValue("Z LEVEL",Answer$)
Stat=SetPickReturn(WsGeometryEnd)
IF (ExitScript(Destination$)) THEN Leave


Pt=PointXYZ(0,0,Zlevel)

T1=AngleTransform(Pt,0,0,0)

Stat=SetWorkplane(T1)
IF IsRulerOn THEN PlotAll

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

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