!   TITLE:  tv_isolate_lines.mac (MANAGEMENT)
!
!
!   TOOLBAR VERSION
!
!   This sub-macro is used to isolate (select out) a set of lines (and
!   associated keypoints) that are to be used in the creation of a new
!   area and/or volume (e.g., using the 'AL' command). The remaining solid
!   model entities are maintained unselected and therefore do not interfere
!   with the line set to be operated on to create new areas and/or volumes.
!
!   Macro code portions are separate sub-sections of a macro as designated
!   in the table of contents.  These sub-sections are stand-alone sections
!   of code that may operate independently.  However, some parameters in a
!   sub-section may be dependent upon pre-existing solid model entities,
!   forcing a sub-section of code to be used in a particular order.
!
!
*get,prkey_,active,0,prkey
/nopr

allsel,all                  ! selects all existing entities
!
*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
!
*get,vm,volu,,num,max
!
*if,vm,ne,vmu,then          ! decision: 'There exists new volumes?'
    !
    cm,vset_10,volu         ! store new volumes in a group
    !
    aslv,selv               ! store all existing entities associated with
        cm,aset_10,area     ! all existing new volumes in groups
    lsla,selv
        cm,lset_10,line
    ksll,selv
        cm,kset_10,kp
        !
    allsel,all              ! selects all existing entities
    !
    *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
    !
    vsel,u,volu,,vset_10        ! unselects all existing solid model entities
    asel,u,area,,aset_10        ! associated with new volumes
    lsel,u,line,,lset_10
    ksel,u,kp,,kset_10
*endif
!
*get,am,area,,num,max
!
*if,am,ne,amu,then          ! decision: 'There exists new areas?'
    !
    cm,aset_20,area         ! store new volumes in a group
    !
    lsla,r                  ! store all existing entities associated
        cm,lset_20,line     ! with all existing new areas in groups
    ksll,r
        cm,kset_20,kp
        !
    asel,u,area,,aset_20
    lsel,u,line,,lset_20    ! unselects all existing solid model
    ksel,u,kp,,kset_20      ! entities associated with new areas
    !
    allsel,all              ! selects all existing entities
    !
    *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
!
*if,vm,ne,vmu,then
    vsel,u,volu,,vset_10        ! unselects all existing solid model entities
    asel,u,area,,aset_10        ! associated with new volumes
    lsel,u,line,,lset_10
    ksel,u,kp,,kset_10
*endif
!
*if,am,ne,amu,then
    asel,u,area,,aset_20        ! unselects all existing solid model
    lsel,u,line,,lset_20        ! entities associated with new areas
    ksel,u,kp,,kset_20
*endif
!
*get,lm,line,,num,max       ! store maximum line # in 'lm'
*get,km,kp,,num,max         ! store maximum keypoint # in 'km'
!
*if,lm,ne,0,then
    _usecntr=1
    ln_tog_=1
    /PNUM,LINE,ln_tog_
    lplot
*else
    _usecntr=1
    kp_tog_=1
    /PNUM,KP,kp_tog_
    kplot
*endif
!
cmdele,vset_10
cmdele,aset_10
cmdele,lset_10
cmdele,kset_10
!
cmdele,aset_20
cmdele,lset_20
cmdele,kset_20

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