
! script name: solids.d/normaldisk
! 3dtopic: construct disk normal to a curve element

!A
!A NAME:
!A
!A 	Disk: Normal Element
!A
!A DESCRIPTION:
!A
!A 	This script will construct a disk of specified radius, angular extent,
!A 	and tilt, normal to an entity.
!A
!B INSTRUCTIONS:
!B
!B 	DISK RADIUS: Enter the radius of the disk to be created.
!B
!B 	STARTING ANGLE: Enter the starting angle of the disk.
!B
!B 	ANGULAR EXTENT: Enter the number of degrees and
!B 		the direction ( + CCW, - CW ) from the starting
!B 		angle to the ending angle.  The angular extent
!B 		determines the ending angle.
!B
!B 	TILT ANGLE: This represents the angle of tilt around
!B 		the tangent vector of the disk.
!B
!B 	PICK NORMAL ENTITY: Pick the element that
!B 		defines the disks normal.
!B
!B 	INPUT ABS X,Y,Z: Enter the X,Y,Z coordinates of
!B 		the point, through which the disk will be
!B 		constructed.  NOTE: See XYZ INPUT OPTIONS.
!B
!C NOTES:
!C
!C 	The U contours of a disk are the circles and the V contours are the
!C 	radial lines.
!C
!# see also - points.d/xyzinput.hlp

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

DIM Destination$[256]
DIM Answer$[256]

ActivateUndo
Astart=0
Angle=180

Cloop:!

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

Stat=SetAngleEquals(Astart)
Astart=InputAngle("STARTING ANGLE")
IF ExitScript(Destination$) THEN Leave

Stat=SetInputFormat("n4=","")
Stat=SetEqualsValue(Angle)
Angle=GetValue("ANGULAR EXTENT",Answer$)
IF ExitScript(Destination$) THEN Leave

Stat=SetInputFormat("n4=","")
Stat=SetEqualsValue(tilt_angle)
Tilt_angle=GetValue("TILT ANGLE",Answer$)
IF ExitScript(Destination$) THEN Leave

Pick_loop:Stat=SetInputFormat("n4","")
Stat=SetPickMask(WsPickNoSurf)
E1=PickEntity("PICK NORMAL ENTITY")
IF ExitScript(Destination$) THEN Leave
IF NOT ValidGeometry(E1) THEN Pick_loop
Stat=SetPickMask(WsPickAll)

Pt=XyzInput("INPUT",WsXyzInput)
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidGeometry(Pt) THEN Pick_loop

Axis_line=TangentLine(E1,Pt,WsTRIMMED)
D1=AxisLineDisk(Axis_line,Radius,Astart,Angle,Tilt_angle,WsForward)
Stat=DeleteEntity(Axis_line)
Stat=DeleteEntity(Pt)

ActivateUndo
Stat= AdvanceUndoNumber("disk")
Stat= AddItemToUndo(WsUBCreateMode,D1)
GOTO Pick_loop

Leave:!
Stat=SetPickMask(WsPickAll)
Stat=SetInputFormat("n4","")
Stat=DeleteEntity(Pt)
Stat=DeleteEntity(Axis_line)

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