!   TITLE:  hole_pattern.mac (SM_TOOL)
!
!
!   OBJECTIVE:
!
!   This sub-macro creates an evenly spaced circular hole pattern about the
!   Z axis of a selected coordinate system.
!
!
!   COMMAND SYNTAX:
!
!                      (1)   (2)   (3)   (4)     (5)    (6)    (7)     (8)
!       HOLE_PATTERN, csnum, rpat, zpos, numh, anginc, stang, patang, dhole
!
!
!   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) dhole = hole diameter
!
!
!   DESCRIPTION:
!
!   The macro is used for creating a series of cylindrical holes in a part
!   area or volumes(s), or for creating a circular patterned set of new
!   cylindrical parts.
!
!
!
*get,prkey_,active,0,prkey
/nopr
!
csnum_=arg1
rpat_=arg2
zpos_=arg3
numh_=arg4
anginc_=arg5
stang_=arg6
patang_=arg7
dhole_=arg8
!
*if,patang_,eq,0,then
    patang_=4*rtangle
*endif
!
*if,numh_,eq,0,then
    numh_=patang_/anginc_
*endif
!
*if,anginc_,eq,0,then
    *if,patang_,lt,4*rtangle,then
        anginc_=patang_/(numh_-1)
    *else
        anginc_=patang_/numh_
    *endif
    !
*endif
!
*if,patang_,eq,4*rtangle,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,csnum_
!
*do,ii_,stang_,maxang_,anginc_
    !
    create_cs,0,'patcs%mm_%',1,rpat_,ii_,zpos_,0,0,0
    !
    cstran=mm_              ! c.s. transfer parameter
    !
    *do,jj_,0,3*rtangle,rtangle
        k,,dhole_/2,jj_,0
    *enddo
    !
    init_entity_num
    !
    a,km-3,km-2,km-1,km
    !
    csys,csnum_
    !
    mm_=mm_+1
*enddo
!
init_entity_num
!
*set,csnum_,
*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

! HOLE_PATTERN,1,5,0,6,,10,,1
!