
! script name: dyn_solids.d/dynplane
! 3dtopic: construct plane of specified length, width, and orientation

!A
!A NAME:
!A
!A 	Dynamic Plane: Define
!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
!B 		along the X axis.
!B
!B 	Y LENGTH: Enter the length of the plane measured
!B 		along the Y axis.
!B
!B 	ROTATION ANGLE: Enter the orientation angle of
!B 		the axis of the plane in the XY plane.
!B
!B 	X AXIS TILT ANGLE: This represents the angle of
!B 		tilt of the axis of the plane around the X axis.
!B
!B 	Y AXIS TILT ANGLE: This represent the angle of
!B 		tilt of the axis of 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/dyninput.hlp

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

DIM Destination$[256]
DIM Answer$[256]
REAL Params(0:10)

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

Stat= GLPlotOn
Start:!
Stat=SetPickMask(WsPickNoSurf)
ActivateUndo
Dynamic_length1= GetDefault(WsDynamicLength1)
Dynamic_length2= GetDefault(WsDynamicLength2)
Dynamic_angle1= GetDefault(WsDynamicAng1Incr)
Dynamic_angle2= GetDefault(WsDynamicAng2Incr)
Dynamic_data1= GetDefault(WsDynamicData1)
Dynamic_data2= GetDefault(WsDynamicData2)

Dynamic_length= GetDefault(WsDynLengthDefault)
Dynamic_angle= GetDefault(WsDynAngleDefault)

Stat= SetDefaults(WsDynamicLength1,Dynamic_length)
Stat= SetDefaults(WsDynamicLength2,Dynamic_length)
Stat= SetDefaults(WsDynamicAng1Incr,Dynamic_angle)
Stat= SetDefaults(WsDynamicAng2Incr,Dynamic_angle)
Stat= SetDefaults(WsDynamicData1,Dynamic_angle)
Stat= SetDefaults(WsDynamicData2,Dynamic_angle)



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

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

Tilt_angles:!
Stat=SetAngleEquals(0)
Zangle=InputAngle("ROTATION ANGLE ( 0 90 180 270 ) ",WsSigned)
IF ExitScript(Destination$) THEN Leave

Stat=SetAngleEquals(0)
Xangle=InputAngle("X AXIS TILT ANGLE ( 0 90 180 270 ) ",WsSigned)
IF ExitScript(Destination$) THEN Leave

Stat=SetAngleEquals(0)
Yangle=InputAngle("Y AXIS TILT ANGLE ( 0 90 180 270 ) ",WsSigned)
IF ExitScript(Destination$) THEN Leave


Place_plane:!
PlotOff
Pref= PointXYZ(0,0,0)
Pdest= CopyEntity(Pref)
Stat= MakeInvisible(Pref)
Stat= MakeInvisible(Pdest)
T1=AngleTransform(Pref,Xangle,Yangle,Zangle,WsWorkplaneVals)
E1=Plane3d(T1,Xlength,Ylength)
Stat= MakeInvisible(E1)
PlotOn

On_center= 0
Vnum= LastPickView
Params(0)= Xlength
Params(1)= Ylength
Params(2)= Xangle
Params(3)= Yangle
Params(4)= Zangle
Params(5)= On_center
Num_params=6
Stat=SetInputFormat("n4b","")
Stat=DynamicEntity(Vnum,E1,Pref,Pdest,WsDynamicPlane,"PICK REFERENCE ",Params,Num_params)
IF (ExitScript(Destination$)) THEN
        Stat=DeleteEntity(E1,WsTrue)
	Stat=DeleteEntity(Pref,WsTrue)
	Stat=DeleteEntity(Pdest,WsTrue)
        IF Destination$= "BACKUP" THEN Tilt_angles
        GOTO Leave
END IF

Stat=DeleteEntity(Pref)
Stat=DeleteEntity(Pdest)

WPKClearErrorFlag
S1=WPKMakeBsurf(E1)
Stat= DeleteEntity(E1,WsTrue)

ActivateUndo
Stat= AdvanceUndoNumber("plane sheet body")
Stat= AddItemToUndo(WsUBPKSessionMark)
WPKErrorCheck
GOTO Place_plane

Leave:!
Stat=SetPickMask(WsPickGeometry)
Stat=SetInputFormat("n4","")
Stat= DeleteEntity(Pref)
Stat= DeleteEntity(Pdest)
Stat= SetDefaults(WsDynamicLength1,Dynamic_length1)
Stat= SetDefaults(WsDynamicLength2,Dynamic_length2)
Stat= SetDefaults(WsDynamicAng1Incr,Dynamic_angle1)
Stat= SetDefaults(WsDynamicAng2Incr,Dynamic_angle2)
Stat= SetDefaults(WsDynamicData1,Dynamic_data1)
Stat= SetDefaults(WsDynamicData2,Dynamic_data2)
IF NOT LEN(Destination$) THEN
	LOAD "typecontrol"
ELSE
	IF Destination$= "SCRIPTSTART" THEN Start
        IF Destination$= "BACKUP" THEN Start
	LOAD Destination$
END IF
END
