!   TITLE:  config_4.mac (MANAGEMENT)
!
!
!   OBJECTIVE:
!
!   This macro stores (or restores) the current (or previous) configuration
!   of the database at an EXTRA configuration group, 4.
!   (i.e., the currently selected set of keypoints, lines, areas, volumes,
!                           nodes, elements, active CS and entity maximums)
!
!
!   COMMAND SYNTAX:
!
!                         (1)
!           CONFIG_4, 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 4) 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
!
save4___=arg1
!
*if,save4___,eq,0,then
    *get,acs4____,active,,csys
    !
    kmhld4__=km
    lmhld4__=lm
    amhld4__=am
    vmhld4__=vm
    nmhld4__=nm
    emhld4__=em
    !
    cm,kgrp4___,kp
    cm,lgrp4___,line
    cm,agrp4___,area
    cm,vgrp4___,volu
    cm,ngrp4___,node
    cm,egrp4___,elem
    !
    cmgrp,curgrp4_,kgrp4___,lgrp4___,agrp4___,vgrp4___,ngrp4___,egrp4___
*elseif,save4___,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,kgrp4___,type
    *get,ltyp____,comp,lgrp4___,type
    *get,atyp____,comp,agrp4___,type
    *get,vtyp____,comp,vgrp4___,type
    *get,ntyp____,comp,ngrp4___,type
    *get,etyp____,comp,egrp4___,type
    !
    *if,ktyp____,eq,6,then
        cmsel,s,kgrp4___
    *endif
    !
    *if,ltyp____,eq,7,then
        cmsel,s,lgrp4___
    *endif
    !
    *if,atyp____,eq,8,then
        cmsel,s,agrp4___
    *endif
    !
    *if,vtyp____,eq,9,then
        cmsel,s,vgrp4___
    *endif
    !
    *if,ntyp____,eq,1,then
        cmsel,s,ngrp4___
    *endif
    !
    *if,etyp____,eq,2,then
        cmsel,s,egrp4___
    *endif
    !
    km=kmhld4__
    lm=lmhld4__
    am=amhld4__
    vm=vmhld4__
    nm=nmhld4__
    em=emhld4__
    !
    csys,acs4____
    !
    *set,ktyp____
    *set,ltyp____
    *set,atyp____
    *set,vtyp____
    *set,ntyp____
    *set,etyp____
*elseif,save4___,eq,-1,then
    cmsel,u,curgrp4_
*elseif,save4___,eq,-2,then
    cmdele,kgrp4___
    cmdele,lgrp4___
    cmdele,agrp4___
    cmdele,vgrp4___
    cmdele,ngrp4___
    cmdele,egrp4___
    cmdele,curgrp4_
    *set,acs4____
*endif
!
*set,save4___,
!
/replot
!
*if,prkey_,eq,1,then
    /go
*endif