
! script name: vsolids.d/lineplane
! var_topic: construct plane along line at an angle

!A
!A NAME:
!A
!A 	Plane: Line	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
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$)


Stat= GenerateVarName(WsPlaneSolidEnt,Name$)
RecordFunctionOn
Stat= RecordDescr("PLANE: line")
Stat= SetRecDelLastExec
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)
Stat= NameEntity(P1,Name$)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord
IF NOT ValidGeometry(P1) THEN
        DelLastVarRecord
ELSE
	ActivateUndo
	Stat= AdvanceUndoNumber("plane")
	Stat= AddItemToUndo(WsUBCreateMode,P1)
	Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
END IF
GOTO Plane_loop

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