!   TITLE:  entity_group.mac (CALCULATION)
!
!
!   OBJECTIVE:
!
!   This sub-macro stores into component groups all selected entities, or
!   reselects the component groups.
!
!   COMMAND SYNTAX:
!
!                        (1)
!        ENTITY_GROUP, restore
!
!
!   ARGUMENTS:
!
!       (1) restore = reselects the currently stored entity groups formed as
!                     a result of execution of this macro.
!
!               0 (or blank) = store all selected entities into respective
!                              component group types.
!
!               1 = select component groups (created as a result of execution
!                   of this macro with this argument set to 0 (or blank)), and
!                   delete the component groups.
!
!               -1 = select component groups (created as a result of execution
!                    of this macro with this argument set to 0 (or blank)), and
!                    DO NOT delete the component groups.
!
!
!   DESCRIPTION:
!
!   Execution of this macro with the 'restore' argument set to 0 (or blank)
!   will store all the currently selected entities in the model database into
!   their respective component groups with specified reserved names (see code
!   below). After any set of analysis or querying operations that result in sel-
!   ecting or unselecting any entities, one may restore that database to the 
!   selected set of entities after the operations are performed. For example,
!   if a set of operations are performed on a selected set of (previously
!   stored) entities, that set may be restored by executing this macro with
!   a 1 in the 'restore' argument.
!
!
!
!
*get,prkey_,active,0,prkey
/nopr
!
rest_=arg1
!
*if,rest_,eq,0,then
    cm,kestr__,kp
    cm,lestr__,line
    cm,aestr__,area
    cm,vestr__,volu
    cm,nestr__,node
    cm,eestr__,elem
*elseif,rest_,eq,1,then
    cmsel,s,kestr__
    cmsel,s,lestr__
    cmsel,s,aestr__
    cmsel,s,vestr__
    cmsel,s,nestr__
    cmsel,s,eestr__
    !
    cmdele,kestr__
    cmdele,lestr__
    cmdele,aestr__
    cmdele,vestr__
    cmdele,nestr__
    cmdele,eestr__
*elseif,rest_,eq,-1,then
    cmsel,s,kestr__
    cmsel,s,lestr__
    cmsel,s,aestr__
    cmsel,s,vestr__
    cmsel,s,nestr__
    cmsel,s,eestr__
*endif
!
*set,rest_,
!
*if,prkey_,eq,1,then
    /go
*endif