
! script name: zplanes.d/parallelplane
! topic: define workplane parallel to existing workplane

!A
!A NAME:
!A
!A 	Parallel Workplane
!A
!A DESCRIPTION:
!A
!A 	This script allows a workplane to be made a parallel distance from
!A 	an existing workplane.
!A
!B INSTRUCTIONS:
!B
!B 	PICK ENTITY FOR EXISTING WORKPLANE: Pick an entity on the existing
!B 		workplane.
!B
!B 	PARALLEL DISTANCE: The perpendicular distance between the existing 
!B 		workplane and the workplane that will be made parallel to it.
!B

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

DIM Answer$[256]
DIM Destination$[256]
stat= SetInputFormat("n4","")

Work=PickEntity("PICK ENTITY FOR EXISTING WORKPLANE")
IF (ExitScript(Destination$)) THEN Leave

Distr=NamedVarVal("parallel distance",WsSystemVars,.5)

Stat=SetEqualsValue(Distr)
Stat=SetInputFormat("n4=","")

Dist= GetValue("PARALLEL DISTANCE",Answer$)
IF (ExitScript(Destination$)) THEN Leave

Stat=SetWorkplane(Work)
Work1= CurrentWorkplane
IF ValidGeometry(Work1) THEN
	Stat=SetWorkplane(Work1)
	T1=ParallelTransform(Work1,Dist)
	Stat=SetWorkplane(T1)
ELSE
	Pt=PointXYZ(0,0,Dist)
	T1=AngleTransform(Pt,0,0,0)
	Stat= DeleteEntity(Pt)
	Stat=SetWorkplane(T1)
END IF
IF IsRulerOn THEN PlotAll


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

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