!   TITLE:  config_5.mac (MANAGEMENT)
!
!
!   OBJECTIVE:
!
!   This macro stores (or restores) the current (or previous) configuration
!   of the database at an EXTRA configuration group, 5.
!   (i.e., the currently selected set of keypoints, lines, areas, volumes,
!                           nodes, elements, active CS and entity maximums)
!
!
!   COMMAND SYNTAX:
!
!                         (1)
!           CONFIG_5, save/restore
!
!
!   ARGUMENTS:
!
!       (1) save/restore = save OR restore the database configuration:
!
!             a.) 0 (or blank) = save the current selected solid model and
!                                finite element (FE) entities. (SAVE MODE)
!
!             b.) 1 = restore (select) the solid model and FE entities
!                     saved in the previous run of this macro in save mode.
!
!             c.) -1 = unselect the solid model and FE entities saved in the
!                      previous run of this macro in save mode.
!
!             d.) -2 = delete any currently saved configurations
!                      (i.e., delete all existing component groups created
!                           by this macro in save mode)
!
!
!   DESCRIPTION:
!
!   This is an additional set (group 5) of stored entities that may be used
!   for resetting the saved configuration.
!
!   (See 'DESCRIPTION' section of the help for macro CONFIGURATION.MAC)
!
!
!
*get,prkey_,active,0,prkey
/nopr
!
save5___=arg1
!
*if,save5___,eq,0,then
    *get,acs5____,active,,csys
    !
    kmhld5__=km
    lmhld5__=lm
    amhld5__=am
    vmhld5__=vm
    nmhld5__=nm
    emhld5__=em
    !
    cm,kgrp5___,kp
    cm,lgrp5___,line
    cm,agrp5___,area
    cm,vgrp5___,volu
    cm,ngrp5___,node
    cm,egrp5___,elem
    !
    cmgrp,curgrp5_,kgrp5___,lgrp5___,agrp5___,vgrp5___,ngrp5___,egrp5___
*elseif,save5___,eq,1,then
    !
    ! 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.).
    !
    *get,ktyp____,comp,kgrp5___,type
    *get,ltyp____,comp,lgrp5___,type
    *get,atyp____,comp,agrp5___,type
    *get,vtyp____,comp,vgrp5___,type
    *get,ntyp____,comp,ngrp5___,type
    *get,etyp____,comp,egrp5___,type
    !
    *if,ktyp____,eq,6,then
        cmsel,s,kgrp5___
    *endif
    !
    *if,ltyp____,eq,7,then
        cmsel,s,lgrp5___
    *endif
    !
    *if,atyp____,eq,8,then
        cmsel,s,agrp5___
    *endif
    !
    *if,vtyp____,eq,9,then
        cmsel,s,vgrp5___
    *endif
    !
    *if,ntyp____,eq,1,then
        cmsel,s,ngrp5___
    *endif
    !
    *if,etyp____,eq,2,then
        cmsel,s,egrp5___
    *endif
    !
    km=kmhld5__
    lm=lmhld5__
    am=amhld5__
    vm=vmhld5__
    nm=nmhld5__
    em=emhld5__
    !
    csys,acs5____
    !
    *set,ktyp____
    *set,ltyp____
    *set,atyp____
    *set,vtyp____
    *set,ntyp____
    *set,etyp____
*elseif,save5___,eq,-1,then
    cmsel,u,curgrp5_
*elseif,save5___,eq,-2,then
    cmdele,kgrp5___
    cmdele,lgrp5___
    cmdele,agrp5___
    cmdele,vgrp5___
    cmdele,ngrp5___
    cmdele,egrp5___
    cmdele,curgrp5_
    *set,acs5____
*endif
!
*set,save5___,
!
/replot
!
*if,prkey_,eq,1,then
    /go
*endif