
! script name: holes.d/hboltcircle
! topic: create partial or full circular pattern of holes

!A
!A NAME:
!A
!A 	Bolt Hole Circle
!A
!A DESCRIPTION:
!A
!A 	This script creates a partial or full circular pattern of holes.
!A
!B INSTRUCTIONS:
!B
!B 	HOLE DIAMETER: Enter the diameter of the hole to be constructed.
!B
!B 	FINISH DEPTH: Enter the depth of the hole to be constructed.
!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 center
!B 		of the circular pattern.  NOTE: See XYZ INPUT OPTIONS.
!B
!B 	STARTING ANGLE: Enter the angle to the first hole of the pattern.
!B
!B 	NUMBER OF POINTS: Enter the number of holes to be constructed.
!B 
!B 	Full or Partial BOLT CIRCLE: Enter "f" for full or "p" for partial
!B 		to indicate which type should be constructed.
!B
!B 		NOTE: If partial is selected, the following question will
!B 		be asked.
!B
!B 	ANGULAR INCREMENT: Enter the number of degrees between the points.
!B 		The angular increment will be calculated automatically for
!B 		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
Bolt_loop:!
Stat=SetInputFormat("n4=","")
Diar=NamedVarVal("hole diameter",WsPointVars,0.0)
Stat=SetRadiusEquals(Diar/2)

Dia=InputRadius("HOLE DIAMETER",WsDiaInput)
IF (ExitScript(Destination$)) THEN Leave
Diar=Dia

Vdia=CreateVariable("hole diameter",WsPointVars,Diar)

Depthr=NamedVarVal("hole depth",WsPointVars,0.0)
Stat=SetDepthEquals(Depthr)

Depth=InputDepth("FINISH DEPTH")
IF (ExitScript(Destination$)) THEN Leave
Depthr=Depth

Vdepth=CreateVariable("hole depth",WsPointVars,Depthr)

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

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

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")
END IF

Group=BoltHole(Radius,Pc,Astart,Ang_inc,Num_pts,Full,Dia,Depth)
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 holes")
Stat= AddGroupToUndo(WsUBCreateMode,Group,1,WsFalse)


GOTO Bolt_loop

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