
! script name: vzplanes.d/parallelplane
! var_topic: define workplane parallel to existing workplane

!A
!A NAME:
!A
!A 	Parallel Workplane	VARIATIONAL
!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
!B 		on the existing workplane.
!B
!B 	PARALLEL DISTANCE: The perpendicular distance
!B 		between the existing workplane and the workplane
!B 		that will be made parallel to it.
!B

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

DIM Answer$[256]
DIM Destination$[256]
DIM Name$[256]
DIM Dist_var$[256]
DIM Element$[256]


Var_object= CheckVarObject
IF (ExitScript(Destination$)) THEN Leave

DeActivateUndo
Distr=NamedVarVal("parallel distance",WsSystemVars,.5)
Stat=SetInputFormat("n4","")

Pick_entity:E1=PickEntity("PICK ENTITY FOR EXISTING WORKPLANE")
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidDependency(E1) THEN Pick_entity
Stat= EntityNameCheck(E1,Element$)

Stat=SetEqualsValue(Distr)
Stat=SetInputFormat("n4=","")
Dist= GetValue("PARALLEL DISTANCE",Answer$)
IF (ExitScript(Destination$)) THEN Leave
No_dist_var= LastVariableInput(Dist_var$)


Stat= GenerateVarName(WsTransformEnt,Name$)
RecordFunctionOn
Stat= RecordDescr("WORKPLANE: Parallel")
Stat=SetWorkplane(Element$)
Trans1= CurrentWorkplane
IF No_dist_var THEN
        V1= FreeParameter("Distance",Dist)
	Trans2=ParallelTransform(Trans1,V1)
ELSE
	Trans2=ParallelTransform(Trans1,Dist_var$)
END IF
Stat=SetWorkplane(Trans2)
Stat= NameEntity(Trans2,Name$)
RecordFunctionOff
CloseVarRecord

Stat= PlotEntity(Element$)
IF IsRulerOn THEN PlotAll


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