!   TITLE:  isolate_kp.mac (MANAGEMENT)
!
!
!   This sub-macro is used to isolate (select out) a set of keypoints (KP)
!   that are unattached to any lines, areas or volumes that may already
!   exist. The remaining solid model entities are maintained unselected
!   and therefore do not interfere with these KP's.
!
!
*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
    !
    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
    !
    *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
*endif
!
*get,lm,line,,num,max
!
*if,lm,ne,lmu,then          ! decision: 'There exists new areas?'
    !
    cm,lset_30,line         ! store new volumes in a group
    !
    ksll,r                  ! store all existing entities associated
        cm,kset_30,kp       ! with all existing new areas in groups
        !
    lsel,u,line,,lset_30    ! unselects all existing solid model
    ksel,u,kp,,kset_30      ! 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
    !
    lsel,u,line,,lset_30        ! entities associated with new areas
    ksel,u,kp,,kset_30
    !
    *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
    !
    *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
*endif
!
*get,km,kp,,num,max                 ! store maximum keypoint # in 'km'
!
kplot
!
cmdele,vset_10
cmdele,aset_10
cmdele,lset_10
cmdele,kset_10
!
cmdele,aset_20
cmdele,lset_20
cmdele,kset_20
!
cmdele,lset_30
cmdele,kset_30

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