!   TITLE:  v_add.mac (SM_TOOL)
!
!
!   OBJECTIVE:
!
!   This sub-macro executes the booleam operation:  volume-addition.
!
!
!   COMMAND SYNTAX:
!
!           v_add, V1, V2, V3, V4, V5, V6, V7, V8, V9
!
!
!   ARGUMENTS:
!
!       (1) V1 = 1st volume(s) to add. (if a component group name is used,
!                                       it must be entered in single quotes)
!
!                V1 = 'all' (or blank): add all selected volumes.
!                                   [arguments 2 thru 9 are ignored]
!
!       (2..9) V2..V9 = additional volume(s) to add. (if a component group
!                                                name is used, it must be
!                                                entered in single quotes)
!
!
!   DESCRIPTION:
!
!   This macro executes the VADD command in ANSYS. Its argument structure is
!   identical in use and sequence as VADD.
!
!   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:
!
!                           vadd,V1,V2
!                           init_entity_num
!                           vplot
!
!   may be replaced with the single line of this macro:
!
!                           v_add,V1,V2
!
!
!
*get,prkey_,active,0,prkey
/nopr
!
v1__=arg1
!
!
! Parameter type: 0=scalar, 1=array, 2=table, 3=character scalar,
!                 4=character array, -1=undefined
!
*get,v1typ_,parm,v1__,type
!
*if,v1typ_,eq,0,then
    *if,v1__,eq,0,then
        xargs__=0
    *elseif,v1__,gt,0,then
        vsel,s,volu,,v1__
        xargs__=1
    *endif
*elseif,v1typ_,eq,3,then
    *if,v1__,ne,'all',then
        cmsel,s,v1__
        xargs__=1
    *elseif,v1__,eq,'all',then
        xargs__=0
    *endif
*endif
!
*if,xargs__,eq,1,then
    *do,ijk__,2,9,1
        v%ijk__%__=arg%ijk__%
        *get,v%ijk__%typ_,parm,v%ijk__%__,type
        !
        *if,v%ijk__%typ_,eq,0,then
            *if,v%ijk__%__,gt,0,then
                vsel,a,volu,,v%ijk__%__
            *endif
        *elseif,v%ijk__%typ_,eq,3,then
            cmsel,a,v%ijk__%__
        *endif
    *enddo
*endif
!
vadd,all
init_entity_num
!
vplot
!
*do,ijk__,1,9,1
    *set,v%ijk__%typ_,
    *set,v%ijk__%__,
*enddo
!
*set,ijk__,
*set,xargs__,
!
*if,prkey_,eq,1,then
    /go
*endif