
! script name: points.d/boltcircle
! topic: create partial or full circular pattern of points

!A
!A NAME:
!A
!A 	Bolt Hole Circle
!A
!A DESCRIPTION:
!A
!A 	This script creates a partial or full circular pattern of points.
!A
!A~ image location - images/boltcircle.jpg
!B INSTRUCTIONS:
!B
!B 	BOLT HOLE RADIUS: Enter the radius to be used for the circular
!B 		pattern.
!B
!B 	BOLT HOLE CENTER ABS X,Y: Enter the X,Y coordinates of the
!B 		center of the circular pattern.
!B
!B 	STARTING ANGLE: Enter the angle to the first point of the pattern.
!B
!B 	NUMBER OF POINTS: Enter the number of points to be
!B 		constructed.
!B
!B 	Full or Partial BOLT CIRCLE: Enter "F" for full or "P" for partial
!B 		to indicate which type should be created.
!B
!B 	NOTE: If partial is selected the following question will be asked.
!B
!B 	ANGULAR INCREMENT: Enter the number of degrees between the
!B 		points.  The angular increment will be calculated
!B 		automatically for a full bolt hole circle.
!B
!# see also - points.d/xyzinput.hlp

stat=ChangeLabelStr("ScriptNameStatus","Function: bolt hole circle ")

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


ActivateUndo
Radiusr=NamedVarVal("bolt hole radius",WsPointVars,1.0)
Stat=SetRadiusEquals(Radiusr)

Bolt_loop:Stat=SetInputFormat("n4=","")
Radius=InputRadius("BOLT HOLE RADIUS")
IF (ExitScript(Destination$)) THEN Leave
Radiusr=Radius
Vradius=CreateVariable("bolt hole radius",WsPointVars,Radiusr)

Pc=XyzInput("BOLT HOLE CENTER",WsXyzInput)
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidGeometry(Pc) THEN Bolt_loop

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

Stat=SetInputFormat("n0","")
Num_pts=GetValue("NUMBER OF POINTS",Answer$)
IF (ExitScript(Destination$)) THEN Leave


Stat=SetInputFormat("a1=",",F,P,")
Stat= SetEqualsValue(0,"F")
Stat=GetValue("Full or Partial BOLT CIRCLE",Answer$)
IF (ExitScript(Destination$)) THEN Leave

IF (Answer$="P") THEN
	Full=WsPartial
ELSE
	Full=WsFull
END IF

Ang_inc=0
Stat=SetInputFormat("n4","")

IF (Full=WsPartial) THEN
	Ang_inc=InputAngle("ANGULAR INCREMENT BETWEEN POINTS")
END IF

Group=BoltHole(Radius,Pc,Astart,Ang_inc,Num_pts,Full,0,0)
IF ValidGeometry(Group) THEN
   Bolt_group=CurrHoleGrpNum
   Bolt_hole$="BOLT HOLE CIRCLE "&VAL$(Bolt_group)
   Stat=ChangeGrpName(Group,Bolt_hole$)
   Bolt_group=Bolt_group+1
   Stat=SetHoleGrpNum(Bolt_group)
END IF

Stat=SetEqualsValue(Radius)
Stat=SetLastPoint(Pc)
Stat=DeleteEntity(Pc)

ActivateUndo
Stat= AdvanceUndoNumber("bolt circle")
Stat= AddGroupToUndo(WsUBCreateMode,Group,WsTrue,WsFalse)

GOTO Bolt_loop

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