!   TITLE:  isolate_areas.mac (MANAGEMENT)
!
!
!           Added argument to isolate areas from an assembly.
!
!   OBJECTIVE:
!
!   This sub-macro is used to isolate (select) any areas that are unattached
!   to any volumes.
!
!
!   COMMAND SYNTAX:
!
!                        (1)
!       ISOLATE_AREAS, assemb
!
!
!   ARGUMENTS:
!
!       (1) assemb = boolean operator for selecting areas from the current
!                    model database or the entire assembly:
!
!               0 (or blank) = isolate areas within the current model.
!
!               1 = isolate areas from the entire assembly.
!
!
!   DESCRIPTION:
!
!   The areas may be newly created as a result of boolean operations or direct
!   generation. The lower solid model entities comprising the areas are also
!   selected (i.e., lines and keypoints).
!
!   This macro is an alternative to the use of the select logic commands in
!   ANSYS. Simply running this command with no arguments will select out all
!   areas that are unattached to volumes within the current model in the
!   database. If it is desired to isolate all areas unnatched to any volumes
!   within an entire assembly, then the argument should be set to 1.
!
!   These areas may then be operated on to create further volumes, or for use
!   in subsequent boolean operations. All remaining solid model entities in
!   the current model database are unselected while operating on these areas.
!
!
!
*get,prkey_,active,0,prkey
/nopr
!
assemb_=arg1
!
allsel,all                  ! selects all existing entities
!
*if,assemb_,eq,0,then
    *if,kp_pssof,gt,0,then      ! unselects all previous model entities
        ksel,u,kp,,_kset_
    *endif
    !
    *if,ln_pssof,gt,0,then
        lsel,u,line,,_lset_
    *endif
    !
    *if,ar_pssof,gt,0,then
        asel,u,area,,_aset_
    *endif
    !
    *if,vl_pssof,gt,0,then
        vsel,u,volu,,_vset_
    *endif
    !
    *if,el_pssof,gt,0,then
        esel,u,elem,,_eset_
    *endif
    !
    *if,nd_pssof,gt,0,then
        nsel,u,node,,_ndset_
    *endif
*endif
!
cm,vset_100,volu            ! store new volumes in a group
!
aslv,selv                   ! store all existing entities associated with
    cm,aset_100,area        ! all existing new volumes in groups
lsla,selv
    cm,lset_100,line
ksll,selv
    cm,kset_100,kp
    !
allsel,all                  ! selects all existing entities
!
*if,assemb_,eq,0,then
    *if,kp_pssof,gt,0,then      ! unselects all previous model entities
        ksel,u,kp,,_kset_
    *endif
    !
    *if,ln_pssof,gt,0,then
        lsel,u,line,,_lset_
    *endif
    !
    *if,ar_pssof,gt,0,then
        asel,u,area,,_aset_
    *endif
    !
    *if,vl_pssof,gt,0,then
        vsel,u,volu,,_vset_
    *endif
    !
    *if,el_pssof,gt,0,then
        esel,u,elem,,_eset_
    *endif
    !
    *if,nd_pssof,gt,0,then
        nsel,u,node,,_ndset_
    *endif
*endif
!
vsel,u,volu,,vset_100       ! unselects all existing solid model entities
asel,u,area,,aset_100       ! associated with new volumes
lsel,u,line,,lset_100
ksel,u,kp,,kset_100
!
lsla,s
ksll,s
!
*get,am,area,,num,max           ! store maximum area # in 'am'
*get,lm,line,,num,max           ! store maximum line # in 'lm'
*get,km,kp,,num,max             ! store maximum keypoint # in 'km'
!
*if,am,ne,0,then
    aplot
*else
    lplot
*endif
!
cmdele,vset_100
cmdele,aset_100
cmdele,lset_100
cmdele,kset_100
*set,assemb_,
!
*if,prkey_,eq,1,then
    /go
*endif