!   TITLE:  vsle.mac (MANAGEMENT)
!
!
!   OBJECTIVE:
!
!   This sub-macro selects a volume associated with a selected element, or
!   set of elements.
!
!   COMMAND SYNTAX:
!
!               (1)
!        VSLE, stype
!
!   ARGUMENTS:
!
!       (1) stype = label outlining the selection type
!
!                   'u' = unselect
!                   's' = select
!                   'r' = reselect
!                   'a' = additionally select
!
!
!   DESCRIPTION:
!
!   A selected element, or set of elements, is/are used to unselect from the
!   current set (u), select from the full set (s), reselect from the current
!   set (r), or additionally select to the current selected set (a), volume(s)
!   containing these elements.
!
!
!
!
*get,prkey_,active,0,prkey
/nopr

styp_=arg1
!
*if,styp_,eq,'s',then
    vsel,all
*elseif,styp_,eq,'a',then
    vsel,all
*else
    cm,selvset_,volu
*endif
!
entity_array,'v','vset10_','array'      ! create array of selected volumes
cm,eset10_,elem
!
*do,jkl_,1,ecount,1
    !
    vsel,s,volu,,vset10_(jkl_,1)
    eslv,s
    cmsel,r,eset10_
    get_max_entity
    *get,elcnt_,elem,,count
    !
    *if,elcnt_,ne,0,then
        *if,jkl_,eq,1,then
            cm,vset2_,volu
        *else
            *get,x_,comp,vset2_,type
            !
            *if,x_,eq,9,then
                cmsel,s,vset2_
                vsel,a,volu,,vm
                cm,vset2_,volu
            *else
                vsel,s,volu,,vm
                cm,vset2_,volu
            *endif
        *endif
    *else
        *if,jkl_,eq,ecount,then
            *get,x_,comp,vset2_,type
            *if,x_,ne,9,then
                vsel,u,volu,,vset10_(jkl_,1)
                cm,vset2_,volu
            *endif
        *endif
    *endif
*enddo
!
*if,styp_,eq,'s',then           ! selection routine
    cmsel,s,vset2_
*elseif,styp_,eq,'u',then
    cmsel,s,selvset_
    cmsel,u,vset2_
*elseif,styp_,eq,'r',then
    cmsel,s,selvset_
    cmsel,r,vset2_
*elseif,styp_,eq,'a',then
    cmsel,s,selvset_
    cmsel,a,vset2_
*endif
!
*set,jkl_,
*set,styp_,
*set,ecount,
*set,elcnt_,
*set,vset10_(1),
*set,x_,
cmdele,selvset_,
cmdele,vset2_,
cmdele,eset10_,


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