!   TITLE:  target_sweep_area.mac (MANAGEMENT)
!
!
!   OBJECTIVE:
!
!   This macro retrieves the opposite (target) area for specification in the
!   VSWEEP command.
!
!
!   COMMAND SYNTAX:
!
!                             (1)      (2)
!       TARGET_SWEEP_AREA, source_A, vol_num
!
!
!   ARGUMENTS:
!
!       (1) source_A = the source area number for volume sweep meshing.
!
!       (2) vol_num = the volumein which to find target area.
!
!
!   DESCRIPTION:
!
!   If the the source area is attached to more than 1 volume, then argument 2
!   specifies which volume to search for the target area.
!
!   The target area specified in the VSWEEP command is determined for volume
!   meshing. The target area is returned in the parameter:
!
!                                   ATARG_
!
!
!
*get,prkey_,active,0,prkey
/nopr
!
sourca__=arg1
volnum__=arg2
!
configuration,0
!
*if,volnum__,eq,0,then
    asel,s,area,,sourca__
    vsla,s,0
    *get,vcount__,volu,,count
    !
    *if,vcount__,eq,1,then
        get_max_entity
        volnum__=vm
        enables_=1
    *elseif,vcount__,gt,1,then
        enables_=0
    *endif
    !
    *set,vcount__,
*else
    enables_=1
*endif
!
*if,enables_,eq,1,then          ! enable select (enables_) = 1
    vsel,s,volu,,volnum__
    aslv,s
    lsla,s
    cm,vset1__,volu
    cm,aset1__,area
    cm,lset1__,line
    !
    asel,r,area,,sourca__
    lsla,r
    ksll,r
    cm,ksetsa_,kp
    !
    cmsel,s,lset1__
    cmsel,s,ksetsa_
    lslk,r,0
    cm,lset2__,line
    !
    cmsel,s,aset1__
    cmsel,s,lset1__
    cmsel,u,lset2__
    !
    asll,r,1
    get_max_entity
    atarg_=am
    !
    cmdele,vset1__
    cmdele,aset1__
    cmdele,lset1__
    cmdele,ksetsa_
    cmdele,lset2__
*endif
!
*set,sourca__,
*set,volnum__,
*set,enables_,
!
configuration,1
!
*if,prkey_,eq,1,then
    /go
*endif