
! script name: vpksheets.d/vpklineplane
! var_solids: construct plane sheet along line at an angle

!A
!A NAME:
!A
!A 	SHEET: plane along line at an angle	VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	This script will construct a plane along a picked line at an angle.
!A
!B INSTRUCTIONS:
!B
!B 	PICK LINE: Pick the line that will define one edge of the plane.
!B
!B 	HEIGHT: Enter the height of the plane to be constructed.
!B
!B 	NORMAL ANGLE: Enter the normal angle to be used for constructing
!B 		the plane.
!B
!C NOTES:
!C
!C 	The U contours of a plane are the lines parallel to the length of
!C 	the plane ( parallel to X axis in an unoriented plane ) and the V
!C 	contours are the lines parallel to the width of the plane ( parallel
!C 	to Y axis in an unoriented plane ).
!C

Stat=ChangeLabelStr("ScriptNameStatus","Function: plane defined along a line at an angle ")

DIM Answer$[256]
DIM Destination$[256]
DIM Height_var$[256]
DIM Angle_var$[256]
DIM Name$[256]
DIM Axis_line$[256]
DEG

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

ActivateUndo
Units= CurrentUnits
IF Units= WsMetric THEN
        Height= 25
ELSE
        Height= 1
END IF
Angle=0.0
Stat= GLPlotOn
Plane_loop:!

Pick_axis:Stat=SetInputFormat("n4","")
Axis_line=PickSpecificEnt("PICK LINE",WsPickLines)
IF ExitScript(Destination$) THEN Leave
IF NOT ValidDependency(Axis_line) THEN Pick_axis
Stat= EntityNameCheck(Axis_line,Axis_line$)
T=LastPickPara
IF T<=0.5 THEN
        Direction= WsForward
ELSE
        Direction= WsReverse
END IF

Stat=SetInputFormat("n4=","")
Stat=SetEqualsValue(Height)
Height=GetValue("HEIGHT",Answer$)
IF ExitScript(Destination$) THEN Leave
No_height_var= LastVariableInput(Height_var$)

Stat=SetAngleEquals(Angle)
Angle=InputAngle("NORMAL ANGLE")
IF ExitScript(Destination$) THEN Leave
No_angle_var= LastVariableInput(Angle_var$)


WPKClearErrorFlag
Stat= GenerateVarName("Body",Name$)
RecordFunctionOn
Stat= RecordDescr("SHEET: plane along line")
IF No_height_var THEN
        V1= FreeParameter("Height",Height)
ELSE
        V1= FreeParameter("Height",Height_var$)
END IF
IF No_angle_var THEN
        V2= FreeParameter("Angle",Angle)
ELSE
        V2= FreeParameter("Angle",Angle_var$)
END IF
P1=LinePlane(Axis_line$,V1,V2,Direction)
RecordFunctionOff
IF ValidGeometry(P1) THEN
        Make_record= WsTrue
        RecordFunctionOn
        Pkbody=WPKBasicSolid(P1)
        Stat= WPKNameBody(Pkbody,Name$)
        Stat= WPKSetBodyParent(Pkbody)
        Stat= DeleteEntity(P1,WsTrue)
        RecordFunctionOff
ELSE
        Make_record= WsFalse
END IF
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord
IF Make_record= WsFalse THEN
        DelLastVarRecord
ELSE
        Stat= WPKSolidRecordOn(Curr_record)
        ActivateUndo
        Stat= AdvanceUndoNumber("plane sheet")
        Stat= AddItemToUndo(WsUBPKSessionMark)
        Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
        WPKErrorCheck
END IF
GOTO Plane_loop

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