!   TITLE:  duplicate_areas.mac (SM_TOOL)
!
!
!   OBJECTIVE:
!
!   This sub-macro duplicates an area (or set of areas) coincident with the
!   original areas.
!
!
!   COMMAND SYNTAX:
!
!                           (1)     (2)
!        DUPLICATE_AREAS, area_num, tol
!
!
!   ARGUMENTS:
!
!       (1) area_num = area to duplicate:
!
!               a.) 0 (or blank) = duplicate the selected set of areas.
!
!               b.) N (where N > 0) = the area number N to be duplicated
!
!               c.) 'comp_name' = component group character name containing
!                                 the areas. [ MUST BE IN SINGLE QUOTES ]
!
!       (2) tol = tolerance value in the duplication of areas. If left blank,
!                 the tolerance value defaults to 1. If it is desired to have
!                 greater accuracy in the duplicated area, this value may be
!                 a higher integer value (2, 3, 4 ...).
!
!
!   DESCRIPTION:
!
!   The areas are duplicated in the same position (coincident) as the original
!   areas unattached to any volumes.
!
!   The default tolerance value for duplicating the source areas (argument 2)
!   is a value of 1. This value suffices for most complex shaped areas. However,
!   if it becomes necessary to have greater accuracy, integer values of 2 or
!   higher may be used. The higher the integer value, the greater the accuracy.
!
!
!
*get,prkey_,active,0,prkey
/nopr
!
arnum_=arg1
tol__=arg2
!
*if,tol__,eq,0,then
    tol__=1
*endif
!
tolint_=10**(-(tol__+3))
!
*get,argtyp1_,parm,arnum_,type
!
*if,argtyp1_,eq,0,then
    *if,arnum_,eq,0,then
        arnum_='cmpaset_'
        cm,%arnum_%,area
    *elseif,arnum_,gt,0,then
        asel,s,area,,arnum_
        arnum_='cmpaset_'
        cm,%arnum_%,area
    *endif
*elseif,argtyp1_,eq,3,then
    cmsel,s,%arnum_%
*endif
!
entity_array,'a','aset__','array'
acnt__=ecount
!
*do,ijk_,1,acnt__
    cmsel,s,%arnum_%
    !
    aoffst,aset__(ijk_,1),tolint_
    !
    *if,assemble,eq,0,then
        init_entity_num
    *else
        init_entity_num,1
    *endif
    !
    aoffst,am,-tolint_
    adele,am,,,1
    !
    *if,assemble,eq,0,then
        init_entity_num
    *else
        init_entity_num,1
    *endif
*enddo
!
aplot
!
cmdele,%arnum_%
*set,arnum_,
*set,argtyp1_,
*set,aset__(1),
*set,acnt__,
*set,ecount,
*set,ijk_,
*set,tol__,
*set,tolint_,
!
*if,prkey_,eq,1,then
    /go
*endif