
! script name: vzplanes.d/parallelangle
! var_topic: workplane parallel to an existing workplane rotated at an angle.

!A
!A NAME:
!A
!A      Parallel Workplane Rotated at an Angle
!A
!A DESCRIPTION:
!A
!A      This script allows a workplane to be made a parallel distance from
!A      an existing workplane rotated about an angle..
!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
!B      ROTATION ANGLE: Give the rotation angle.
!B

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

DIM Answer$[256]
DIM Destination$[256]
DIM Name$[256]
DIM Dist_var$[256]
DIM Angle_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$)

Angle_ques:Angle=InputAngle("ROTATION ANGLE")
IF (ExitScript(Destination$)) THEN Leave
No_angle_var= LastVariableInput(Angle_var$)
L1= LastPickEnt
IF ValidGeometry(L1) THEN
        IF NOT ValidDependency(L1) THEN Angle_ques
        Stat= EntityNameCheck(L1,Angle_var$)
        No_angle_var=0
END IF

Stat= GenerateVarName(WsTransformEnt,Name$)
RecordFunctionOn
Stat= RecordDescr("WORKPLANE: Parallel At Angle")
Stat=SetWorkplane(Element$)
Trans1= CurrentWorkplane
IF No_dist_var THEN
        V1= FreeParameter("Distance",Dist)
ELSE
        V1= FreeParameter("Distance",Dist_var$)
END IF
IF No_angle_var THEN
        V2= FreeParameter("Angle",Angle)
	Trans2=ParallelTransform(Trans1,V1,V2)
ELSE
	Trans2=ParallelTransform(Trans1,V1,Angle_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
