!   TITLE:  cir_ara_pattern.mac (SM_TOOL)
!
!
!   This macro creates a pattern of areas by repeating an area, or selected
!   set of areas, about the center of the active coordinate system (CS).
!
!   The active CS may be any type of CS (i.e., cartesian, cylindrical, etc.).
!   The origin of the active CS only serves as a center of rotation for the
!   area pattern. Only the existing area(s) which are to be patterned should
!   be selected.  They are stored in a component group and their pattern
!   repeated about the center of the active CS.
!
!   The pattern of areas may be created by either specifying the number of
!   patterns, or by specifying the repeat angle of the pattern. In addition,
!   the total pattern angle defaults to 360, or a total pattern angle between
!   0 and 360 may be specified.
!
!   The arguments for this macro are as follows:
!
!       (1)  num_pats = The number of repeat patterns to be created
!                       within the total pattern angle. When specifying
!                       this parameter, argument 2 (ANG_INC) must be
!                       left blank.
!
!       (2)  ang_inc = The angle between repeated area patterns. Specifying
!                      this parameter over-rides argument 1 (NUM_PATS),
!                      and will use this value to create the pattern. This
!                      parameter must be an integral divisor of the total
!                      pattern angle (PAT_ANG).
!
!       (3)  pat_ang = The total pattern angle.  This parameter defaults
!                      to 360, but may be specified with an angle value
!                      between 0 and 360.
!
!
!
!                     (1)      (2)      (3)
! CIR_ARA_PATTERN, num_pats, ang_inc, pat_ang
!
!
!
*get,prkey_,active,0,prkey
/nopr

numpats_=arg1
anginc_=arg2
patang_=arg3
!
cm,sourcea_,area
!
*get,basecs_,active,,csys
patcs_=basecs_
*get,ccstyp_,cdsy,basecs_,attr,kcs
!
*if,ccstyp_,ne,1,then
    create_cs,0,'patcs_',1,0,0,0,0,0,0
*endif
!
*if,patang_,eq,0,then
    patang_=360
*elseif,patang_,ge,360,then
    patang_=360
*endif
!
*if,anginc_,eq,0,then
    *if,patang_,eq,360,then
        anginc_=patang_/numpats_
        aoffset_=2*anginc_
    *else
        anginc_=patang_/(numpats_-1)
        aoffset_=anginc_
    *endif
*else
    *if,patang_,eq,360,then
        aoffset_=2*anginc_
    *else
        aoffset_=anginc_
    *endif
*endif
!
arnum_=0
!
*do,xyz_,0,(patang_-aoffset_),anginc_
    !
    csys,patcs_
    !
    arnum_=arnum_+1
    !
    create_cs,0,,1,0,0,0,arnum_*anginc_,0,0
    !
    csys,patcs_
    !
    atran,csn+1,sourcea_,,,,0,0
    !
    init_entity_num
*enddo
!
csys,basecs_
!
*set,numpats_,
*set,anginc_,
*set,aoffset_,
*set,radpat_,
*set,strtang_,
*set,patang_,
*set,arnum_,
*set,xyz_,
*set,basecs_,
*set,patcs_,
*set,ccstyp_,
cmdele,sourcea_
:w

*if,prkey_,eq,1,then
    /go
*endif