!   TITLE:  a_add.mac (SM_TOOL)
!
!
!   OBJECTIVE:
!
!   This sub-macro executes the booleam operation:  area-addition.
!
!
!   COMMAND SYNTAX:
!
!           a_add, A1, A2, A3, A4, A5, A6, A7, A8, A9
!
!
!   ARGUMENTS:
!
!       (1) A1 = 1st area(s) to add. (if a component group name is used, it
!                                       must be entered in single quotes)
!
!                A1 = 'all' (or blank): add all selected areas.
!                                   [arguments 2 thru 9 are ignored]
!
!       (2..9) A2..A9 = additional area(s) to add. (if a component group name
!                                                   is used, it must be
!                                                   entered in single quotes)
!
!
!   DESCRIPTION:
!
!   This macro executes the AADD command in ANSYS. Its argument structure is
!   identical in use and sequence as AADD.
!
!   The added advantage and rationale for this macro command is the automatic
!   update of the solid model entities maximums (INIT_ENTITY_NUM is used
!   internally), thereby eliminating essentially 2 lines of code with the use
!   of 1. Therefore the lines of code:
!
!                           aadd,A1,A2
!                           init_entity_num
!                           aplot
!
!   may be replaced with the single line of this macro:
!
!                           a_add,A1,A2
!
!
!
*get,prkey_,active,0,prkey
/nopr
!
a1__=arg1
!
!
! Parameter type: 0=scalar, 1=array, 2=table, 3=character scalar,
!                 4=character array, -1=undefined
!
*get,a1typ_,parm,a1__,type
!
*if,a1typ_,eq,0,then
    *if,a1__,eq,0,then
        xargs__=0
    *elseif,a1__,gt,0,then
        asel,s,area,,a1__
        xargs__=1
    *endif
*elseif,a1typ_,eq,3,then
    *if,a1__,ne,'all',then
        cmsel,s,a1__
        xargs__=1
    *elseif,a1__,eq,'all',then
        xargs__=0
    *endif
*endif
!
*if,xargs__,eq,1,then
    *do,ijk__,2,9,1
        a%ijk__%__=arg%ijk__%
        *get,a%ijk__%typ_,parm,a%ijk__%__,type
        !
        *if,a%ijk__%typ_,eq,0,then
            *if,a%ijk__%__,gt,0,then
                asel,a,area,,a%ijk__%__
            *endif
        *elseif,a%ijk__%typ_,eq,3,then
            cmsel,a,a%ijk__%__
        *endif
    *enddo
*endif
!
aadd,all
init_entity_num
!
aplot
!
*do,ijk__,1,9,1
    *set,a%ijk__%typ_,
    *set,a%ijk__%__,
*enddo
!
*set,ijk__,
*set,xargs__,
!
*if,prkey_,eq,1,then
    /go
*endif