!   TITLE:  hole_pattern.mac (SM_TOOL)
!
!
!       Modified code to allow for varying number of arcs used to create
!       the hole areas, and the start angle for those arcs on each hole
!       (arguments 9 and 10). Also, made provision for keeping or deleting
!       the CS at the center of each circular area (argument 11).
!
!   OBJECTIVE:
!
!   This sub-macro creates an evenly spaced circular pattern of circular
!   areas.
!
!
!   COMMAND SYNTAX:
!
!                      (1)   (2)   (3)   (4)     (5)    (6)    (7)
!       HOLE_PATTERN, csnum, rpat, zpos, numh, anginc, stang, patang,
!
!                     d_area, Narcs, stang_arcs, CS_delete
!                       (8)    (9)      (10)       (11)
!
!
!   ARGUMENTS:
!
!       (1) csnum = coordinate system number that the pattern is con-
!                   structed around (must be a cylindrical c.s.)
!
!       (2) rpat = radius of hole pattern (i.e., the radial distance at
!                  which the hole local c.s. is placed)
!
!       (3) zpos = z position relative to 'csnum' at which the pattern
!                  is created
!
!       (4) numh = number of holes around the perimeter (if left blank,
!                  then the angular increment must be specified)
!
!       (5) anginc = angular spacing increment for the hole pattern
!                    (if left blank, then the number of holes must
!                    be specified)
!
!       (6) stang = start angle at which the pattern is initiated
!
!       (7) patang = the total pattern angle, measured from 'stang'
!                    (if left blank, defaults to 360)
!
!       (8) d_area = area diameters
!
!       (9) Narcs = number of arced lines constructing the holes.
!                   [Defaults to 4 arcs if left blank]
!
!       (10) stang_arcs = start angle of the arcs for each hole area.
!                         [Defaults to 0 if left blank]
!
!       (11) CS_delete = boolean operator to determine whether to delete
!                        pattern coordinate system at the center of each
!                        circular area:
!
!                   0 (or blank) = keep coordinate systems
!
!                   1 = delete coordinate systems
!
!
!   DESCRIPTION:
!
!   The macro is used for creating a series of circular areas in a circular
!   pattern about the Z axis of the specified coordinate system (argument 1).
!   The area centers are located at specified angular increments at a given
!   radius, with specified diameters.
!
!   Coordinate systems are at the center of each circular area. The coordinate
!   systems may be kept or deleted by specifying argument 11.
!
!   *** IMPORTANT: The newly created areas are stored in a component group
!                  for use in subsequent boolean operations. The areas are
!                  stored in a component group named:
!
!                                   new_ars
!
!
!
*get,prkey_,active,0,prkey
/nopr
!
hpcsnum_=arg1
rpat_=arg2
zpos_=arg3
numh_=arg4
anginc_=arg5
stang_=arg6
patang_=arg7
dhole_=arg8
nharcs_=arg9
staarcs_=ar10
delcs_=ar11
!
csys,hpcsnum_
clocal,csn+1e6,1,0,0,0,0,0,0
hpcsnum_=csn+1e6
!
*if,patang_,eq,0,then
    patang_=360
*endif
!
*if,numh_,eq,0,then
    numh_=patang_/anginc_
*else
    anginc_=0
*endif
!
*if,nharcs_,eq,0,then
    nharcs_=4
*endif
!
*if,anginc_,eq,0,then
    *if,patang_,lt,360,then
        anginc_=patang_/(numh_-1)
    *else
        anginc_=patang_/numh_
    *endif
*endif
!
*if,patang_,eq,360,then
    maxang_=stang_+patang_-anginc_
*else
    maxang_=stang_+patang_
*endif
!
*if,cstran,ne,0,then        ! coordinate system counter
    mm_=cstran+1
*else
    mm_=1
*endif
!
csys,hpcsnum_
!
*do,ii_,stang_,maxang_,anginc_
    create_cs,0,'patcs%mm_%',1,rpat_,ii_,zpos_,0,0,0
    cstran=mm_
    !
    create_circ_area,dhole_/2,,,nharcs_,staarcs_
    !
    *if,delcs_,eq,1,then
        csdele,patcs%mm_%
    *endif
    !
    csys,hpcsnum_
    mm_=mm_+1
    !
*enddo
!
init_entity_num
asel,s,area,,am-(numh_-1),am
cm,new_ars,area
init_entity_num
!
aplot
!
csdele,hpcsnum_
*set,hpcsnum_,
*set,rpat_,
*set,zpos_,
*set,numh_,
*set,anginc_,
*set,stang_,
*set,patang_,
*set,dhole_,
*set,maxang_,
*set,mm_,
*set,ii_,
*set,jj_,
!
*if,prkey_,eq,1,then
    /go
*endif