!   TITLE:  config_2.mac (MANAGEMENT)
!
!
!   OBJECTIVE:
!
!   This macro stores (or restores) the current (or previous) configuration
!   of the database at an EXTRA configuration group, 2.
!   (i.e., the currently selected set of keypoints, lines, areas, volumes,
!                           nodes, elements, active CS and entity maximums)
!
!
!   COMMAND SYNTAX:
!
!                         (1)
!           CONFIG_2, 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 2) 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
!
save2___=arg1
!
*if,save2___,eq,0,then
    *get,acs2____,active,,csys
    !
    kmhld2__=km
    lmhld2__=lm
    amhld2__=am
    vmhld2__=vm
    nmhld2__=nm
    emhld2__=em
    !
    cm,kgrp2___,kp
    cm,lgrp2___,line
    cm,agrp2___,area
    cm,vgrp2___,volu
    cm,ngrp2___,node
    cm,egrp2___,elem
    !
    cmgrp,curgrp2_,kgrp2___,lgrp2___,agrp2___,vgrp2___,ngrp2___,egrp2___
*elseif,save2___,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,kgrp2___,type
    *get,ltyp____,comp,lgrp2___,type
    *get,atyp____,comp,agrp2___,type
    *get,vtyp____,comp,vgrp2___,type
    *get,ntyp____,comp,ngrp2___,type
    *get,etyp____,comp,egrp2___,type
    !
    *if,ktyp____,eq,6,then
        cmsel,s,kgrp2___
    *endif
    !
    *if,ltyp____,eq,7,then
        cmsel,s,lgrp2___
    *endif
    !
    *if,atyp____,eq,8,then
        cmsel,s,agrp2___
    *endif
    !
    *if,vtyp____,eq,9,then
        cmsel,s,vgrp2___
    *endif
    !
    *if,ntyp____,eq,1,then
        cmsel,s,ngrp2___
    *endif
    !
    *if,etyp____,eq,2,then
        cmsel,s,egrp2___
    *endif
    !
    km=kmhld2__
    lm=lmhld2__
    am=amhld2__
    vm=vmhld2__
    nm=nmhld2__
    em=emhld2__
    !
    csys,acs2____
    !
    *set,ktyp____
    *set,ltyp____
    *set,atyp____
    *set,vtyp____
    *set,ntyp____
    *set,etyp____
*elseif,save2___,eq,-1,then
    cmsel,u,curgrp2_
*elseif,save2___,eq,-2,then
    cmdele,kgrp2___
    cmdele,lgrp2___
    cmdele,agrp2___
    cmdele,vgrp2___
    cmdele,ngrp2___
    cmdele,egrp2___
    cmdele,curgrp2_
    *set,acs2____
*endif
!
*set,save2___,
!
/replot
!
*if,prkey_,eq,1,then
    /go
*endif