!   TITLE:  select.mac (MANAGEMENT)
!
!
!   OBJECTIVE:
!
!   This sub-macro selects and displays components or parts in an assembly.
!
!
!   COMMAND SYNTAX:
!
!                       (1)           (2)         (3)
!           SELECT, 'part_name', 'select_typ', FE_entity
!
!
!           SELECT (no arguments specified) = all entities are selected.
!
!
!   ARGUMENTS:
!
!       (1) part_name = part component character name (Must be in single
!                       quotes). If left blank (along with the remaining
!                       arguments), then all entities are selected.
!
!       (2) select_typ = selecttion type: [ Must be in single quotes ]
!
!                   's' = select a new set
!
!                   'r' = reselect from a currently selected set
!
!                   'a' = also (additionally) select
!
!                   'u' = unselect
!
!       (3) FE_entity = boolean to determine if to select nodes and
!                       elements associated with the solid model entity:
!
!               1 (or blank) = display FE entities.
!
!               -1 = DO NOT display FE entities.
!
!
!   DESCRIPTION:
!
!   The parts and their lower entities are selected and displayed. If nodes
!   and elements are also desired to be displayed, then argument 3 needs to
!   be specified.
!
!   If 'SELECT' is executed with no arguments, all entities are selected and
!   a line plot is displayed.
!
!   The ANSYS conventions for select logic are followed.
!
!
!
*get,prkey_,active,0,prkey
/nopr
!
partn__=arg1
selectt_=arg2
fe_ent__=arg3
!
unsflag_=0
!
*get,prtptyp_,parm,partn__,type
*get,selptyp_,parm,selectt_,type
!
! Parameter type: 0=scalar, 1=array, 2=table, 3=character scalar,
!                 4=character array, -1=undefined
!
*get,cmptyp_,comp,partn__,type
!
! Type of component Cname:
!       1=Nodes, 2=Elements, 6=Keypoints, 7=Lines, 8=Areas, 9=Volumes,
!       11-15=Subcomponents
!       (11=subcomponent at level 1, 12=subcomponent at level 2, etc.).
!
*if,prtptyp_,eq,0,then
    init_entity_num,1
    /auto,1
    lplot
*else
   *if,selptyp_,eq,0,then
        selectt_='s'
        selptyp_=3
    *endif
    !
    *if,fe_ent__,eq,0,then
        fe_ent__=1
    *endif
    !
   *if,selptyp_,eq,3,then
        *if,selectt_,eq,'u',then
            selectt_='s'
            unsflag_=1
            cm,kgrp1___,kp
            cm,lgrp1___,line
            cm,agrp1___,area
            cm,vgrp1___,volu
            cm,ngrp1___,node
            cm,egrp1___,elem
        *endif
    *endif
    !
    cmsel,selectt_,partn__
    !
    *if,cmptyp_,eq,7,then
        ksll,selectt_
        !
        *if,fe_ent__,eq,1,then
            esll,selectt_
            nsle,selectt_,all
            !
            *get,ecnt__,elem,0,count
            !
            *if,ecnt__,eq,0,then
                /auto,1
                lplot
            *else
                /auto,1
                eplot
            *endif
        *elseif,fe_ent__,eq,-1,then
            /auto,1
            lplot
        *endif
    *elseif,cmptyp_,eq,8,then
        *if,selectt_,eq,'s',then
            vsel,none
        *endif
        !
        lsla,selectt_
        ksll,selectt_
        !
        *if,fe_ent__,eq,1,then
            esla,selectt_
            esll,a
            nsle,selectt_,all
        *endif
        !
        *if,unsflag_,eq,1,then
            configuration,0,,1
            init_entity_num,1
            cmsel,r,kgrp1___
            cmsel,r,lgrp1___
            cmsel,r,agrp1___
            cmsel,r,vgrp1___
            cmsel,r,ngrp1___
            cmsel,r,egrp1___
            configuration,-1,,1
         *endif
        !
        *if,fe_ent__,eq,1,then
            *get,ecnt__,elem,0,count
            !
            *if,ecnt__,eq,0,then
                /auto,1
                aplot
            *else
                /auto,1
                eplot
            *endif
        *elseif,fe_ent__,eq,-1,then
            /auto,1
            vplot
        *endif
    *elseif,cmptyp_,eq,9,then
        aslv,selectt_
        lsla,selectt_
        ksll,selectt_
        !
        *if,fe_ent__,eq,1,then
            eslv,selectt_
            esla,a
            esll,a
            nsle,selectt_,all
        *endif
        !
        *if,unsflag_,eq,1,then
            configuration,0,,1
            init_entity_num,1
            cmsel,r,kgrp1___
            cmsel,r,lgrp1___
            cmsel,r,agrp1___
            cmsel,r,vgrp1___
            cmsel,r,ngrp1___
            cmsel,r,egrp1___
            configuration,-1,,1
         *endif
        !
        *if,fe_ent__,eq,1,then
            *get,ecnt__,elem,0,count
            !
            *if,ecnt__,eq,0,then
                /auto,1
                vplot
            *else
                /auto,1
                eplot
            *endif
        *elseif,fe_ent__,eq,-1,then
            /auto,1
            vplot
        *endif
    *endif
*endif
!
*set,partn__,
*set,selectt_,
*set,fe_ent__,
*set,cmptyp_,
*set,selptyp_,
*set,ecnt__,
*set,prtptyp_,
*set,unsflag_,
!
*if,prkey_,eq,1,then
    /go
*endif