
! script name: vsolids.d/plane
! var_topic: construct plane of specified length, width, and orientation

!A
!A NAME:
!A
!A 	Plane: Define	VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	This script will construct a plane of specified length, width, and
!A 	orientation.
!A
!B INSTRUCTIONS:
!B
!B 	X LENGTH: Enter the length of the plane measured along the X axis.
!B
!B 	Y LENGTH: Enter the length of the plane measured along the Y axis.
!B
!B 	REFERENCE POINT ABS X,Y,Z: Enter the X,Y,Z coordinates of the lower
!B 		left-hand corner of the plane.  NOTE: See XYZ INPUT OPTIONS.
!B
!B 	ROTATION ANGLE: Enter the orientation angle of the axis of the plane
!B 		in the XY plane.
!B
!B 	X AXIS TILT ANGLE: This represents the angle of tilt of the axis of
!B 		the plane around the X axis.
!B
!B 	Y AXIS TILT ANGLE: This represent the angle of tilt of the axis of
!B 		the plane around the Y axis.
!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
!# see also - points.d/xyzinput.hlp

Stat=ChangeLabelStr("ScriptNameStatus","Function: plane ")

DIM Destination$[256]
DIM Answer$[256]
DIM Xlength_var$[256]
DIM Ylength_var$[256]
DIM Name$[256]
DIM Center$[256]
DIM Xangle_var$[256]
DIM Yangle_var$[256]
DIM Zangle_var$[256]

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

ActivateUndo
Units= CurrentUnits
IF Units= WsMetric THEN
	Xlength= 100
	Ylength= 100
ELSE
	Xlength= 5
	Ylength= 5
END IF

Cloop:!

Stat=SetInputFormat("n4=","")
Stat=SetEqualsValue(Xlength)
XLength=GetValue("X LENGTH",Answer$)
IF ExitScript(Destination$) THEN Leave
No_xlength_var= LastVariableInput(Xlength_var$)

Stat=SetInputFormat("n4=","")
Stat=SetEqualsValue(Ylength)
YLength=GetValue("Y LENGTH",Answer$)
IF ExitScript(Destination$) THEN Leave
No_ylength_var= LastVariableInput(Ylength_var$)

Pick_point:Stat=SetInputFormat("n4=","")
E1=PickEntity("REFERENCE POINT")
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidDependency(E1) THEN Pick_point
T= LastPickPara
Pick_return= CurrPickReturn
Stat= EntityNameCheck(E1,Center$)
Pc= ParameterReturnPt(E1,T,Pick_return)
Stat=SetEqualsValue(Radius)
Stat=SetLastPoint(Pc)
Stat= DeleteEntity(Pc)


Stat=SetAngleEquals(0)
Zangle=InputAngle("ROTATION ANGLE ",WsSigned)
IF ExitScript(Destination$) THEN Leave
No_zangle_var= LastVariableInput(Zangle_var$)

Stat=SetAngleEquals(0)
Xangle=InputAngle("X AXIS TILT ANGLE ",WsSigned)
IF ExitScript(Destination$) THEN Leave
No_xangle_var= LastVariableInput(Xangle_var$)

Stat=SetAngleEquals(0)
Yangle=InputAngle("Y AXIS TILT ANGLE ",WsSigned)
IF ExitScript(Destination$) THEN Leave
No_yangle_var= LastVariableInput(Yangle_var$)

Stat= GenerateVarName(WsPlaneSolidEnt,Name$)
RecordFunctionOn
Stat= RecordDescr("PLANE: Define")
Stat= SetRecDelLastExec
SELECT Pick_return
CASE WsGeometryEnd
        Pc= ParameterReturnPt(Center$,T,WsGeometryEnd)
CASE WsGeometryMid
        Pc= ParameterReturnPt(Center$,T,WsGeometryMid)
CASE WsGeomCenter
        Pc= ParameterReturnPt(Center$,T,WsGeomCenter)
END SELECT
IF No_xlength_var THEN
        V1= FreeParameter("Xlength",Xlength)
ELSE
        V1= FreeParameter("Xlength",Xlength_var$)
END IF
IF No_ylength_var THEN
        V2= FreeParameter("Ylength",Ylength)
ELSE
        V2= FreeParameter("Ylength",Ylength_var$)
END IF
IF No_xangle_var THEN
        V3= FreeParameter("X Angle",Xangle)
ELSE
        V3= FreeParameter("X Angle",Xangle_var$)
END IF
IF No_yangle_var THEN
        V4= FreeParameter("Y Angle",Yangle)
ELSE
        V4= FreeParameter("Y Angle",Yangle_var$)
END IF
IF No_zangle_var THEN
        V5= FreeParameter("Z Angle",Zangle)
ELSE
        V5= FreeParameter("Z Angle",Zangle_var$)
END IF
Trans1=AngleTransform(Pc,V3,V4,V5,WsWorkplaneVals)
C1=Plane3d(Trans1,V1,V2)
Stat= NameEntity(C1,Name$)
Stat= DeleteEntity(Pc)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord
IF NOT ValidGeometry(C1) THEN
        DelLastVarRecord
ELSE
	ActivateUndo
	Stat= AdvanceUndoNumber("plane")
	Stat= AddItemToUndo(WsUBCreateMode,C1)
	Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
END IF
GOTO Cloop

Leave:!
Stat=DeleteEntity(Pt)

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