
! script name: macros.d/cpocket
! EXAMPLE: construct radial pocket

!A
!A NAME:
!A
!A 	Radial Pocket
!A
!A DESCRIPTION:
!A
!A 	This script creates a radial pocket.
!A
!B INSTRUCTIONS:
!B
!B 	CIRCLE CENTER ABS X,Y: Enter the X,Y coordinates for the center
!B 		of the radial pocket.  NOTE: See XYZ INPUT OPTIONS.
!B
!B 	INNER RADIUS: Enter the radius of the inner circle to be used
!B 		in creating the radial pocket.
!B
!B 	OUTER RADIUS: Enter the radius of the outer circle to be used
!B 		in creating the radial pocket.
!B
!B 	CORNER RADIUS: Enter the radius to be used for connecting the
!B 		inner and outer radii.
!B
!B 	STARTING ANGLE: Enter the orientation angle for the start of the
!B 		pocket.
!B
!B 	ENDING ANGLE: Enter the orientation angle for the end of the pocket.
!B
!# see also - points.d/xyzinput.hlp

stat=ChangeLabelStr("ScriptNameStatus","Function: radial pocket ")

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

DeActivateUndo
Rect_loop:!

Stat=SetInputFormat("n4=","")
Pc=XyzInput("CIRCLE CENTER ",WsXyOnly)
IF (ExitScript(Destination$)) THEN Leave

R1=InputRadius("INNER RADIUS")
IF (ExitScript(Destination$)) THEN Leave

R2=InputRadius("OUTER RADIUS")
IF (ExitScript(Destination$)) THEN Leave

Corner=InputRadius("CORNER RADIUS")
IF (ExitScript(Destination$)) THEN Leave

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

Aend=InputAngle("ENDING ANGLE")
IF (ExitScript(Destination$)) THEN Leave


C1=RadiusCenter(R1,Pc)
C2=RadiusCenter(R2,Pc)

L1=PointAngle(Pc,Astart,WsTRIMMED)
L2=PointAngle(Pc,Aend,WsTRIMMED)

C3=Fillet(Corner,C1,WsOutside,L1,WsLeft,2)
C4=Fillet(Corner,C1,WsOutside,L2,WsRight,2)

C5=Fillet(Corner,C2,WsInside,L1,WsLeft,2)
C6=Fillet(Corner,C2,WsInside,L2,WsRight,2)

Contour=CreateGroup("CONTOUR",WsContourGroup)
Number= GroupCount(Contour)
Econnect= GroupElement(Contour,number)

Smode= WsMultipleAuto
Direction=WsForward
Group=AutoSequence("TempContour",C1,C1,Econnect,Smode,Direction,2,WsAutoseqPen)

IF (ValidGeometry(Group)) THEN
		Stat=CombineGroups(Contour,Group)
		Stat=DeleteEntity(Group)
		Stat=ColorContour(Contour)

		N1=GroupCount(Contour)
		IF (N1=0) THEN
			Stat=DeleteEntity(Contour)
		ELSE
			Stat=AutoNumberCont(Contour)
		END IF

END IF

Stat=DeleteEntity(Pc)

GOTO Rect_loop

Leave:!
Stat=DeleteEntity(Pc)
IF (NOT LEN(Destination$)) THEN
	 LOAD "typecontrol"
ELSE
	 LOAD Destination$
END IF
END
