
! script name: pkdyn_solids.d/pkdyndisk
! solids: construct disk sheet

!A
!A NAME:
!A
!A 	Dynamic Disk: Define
!A
!A DESCRIPTION:
!A
!A 	This script constructs a disk sheet body, which is
!A 	a plane with a circular boundary.
!A
!B INSTRUCTIONS:
!B
!B 	DISK RADIUS: Enter the radius of the disk to be constructed.
!B
!B 	ROTATION ANGLE: Enter the orientation angle of the axis of the disk
!B 		in the XY plane.
!B
!B 	X AXIS TILT ANGLE: This represents the angle of tilt of the axis of
!B 		the disk around the X axis.
!B
!B 	Y AXIS TILT ANGLE: This represents the angle of tilt of the axis of
!B 		the disk around the Y axis.
!B
!# see also - points.d/dyninput.hlp
!# see also - htdocs/help.d/parasolids.htm

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

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

Units= CurrentUnits
IF Units= WsMetric THEN
        Radius= 25
ELSE
        Radius= 1
END IF


Stat= GLPlotOn
Start:!
Stat=SetPickMask(WsPickNoSurf)
ActivateUndo
Astart= 0
Angle= 180

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_radius= GetDefault(WsDynRadiusDefault)
Dynamic_angle= GetDefault(WsDynAngleDefault)

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



Stat=SetInputFormat("n4b=","")
Stat=SetRadiusEquals(Radius)
Radius=InputRadius("DISK RADIUS")
IF ExitScript(Destination$) THEN Leave


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

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

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


Place_disk:!
Astart= 0.0
Disk_angle= 360.0
PlotOff
Pref= PointXYZ(0,0,0)
Pdest= CopyEntity(Pref)
Stat= MakeInvisible(Pref)
Stat= MakeInvisible(Pdest)
T1=AngleTransform(Pref,Xangle,Yangle,Zangle,WsWorkplaneVals)
E1=Disk(T1,Radius,Astart,Disk_angle)
Stat= MakeInvisible(E1)
Stat= hideEntity(E1)
PlotOn

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

Stat=DeleteEntity(Pref)
Stat=DeleteEntity(Pdest)
Stat= PlotEntity(E1)

WPKClearErrorFlag
E2=WPKBasicSolid(E1)
Stat=DeleteEntity(E1)

ActivateUndo
Stat= AdvanceUndoNumber("disk sheet")
Stat= AddItemToUndo(WsUBPKSessionMark)
WPKErrorCheck

GOTO Place_disk

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

