! ANSYS $RCSfile: EDPC.MAC,v $
! Modified on $Date: 2010-11-14 13:40:31 -0500 (Sun, 14 Nov 2010) $ 
! Source ID = $Revision: 435640 $
!  -------------------------------------------------------------------------
!   This macro is designed to plot
!   contact entities for explicit dynamics.
!
!
!   Proper execution of this macro requires the following:
!
!   Use this macro as follows:
!
!   edpc,Min,Max,Inc
!
!   where: Min - Minimum contact definition number.
!          Max - Maximum contact definition number.
!          Inc - Increment.
!              
!  -------------------------------------------------------------------------

/nopr
*get,_count,edcc,,count

_key10=0

*if,arg1,eq,0.0,then

*if,arg2,eq,0.0,then
  arg1=1.0 
  arg2=_count
*else
  arg1=1.0 
  arg2=_count
/gopr
*msg,warn,arg2,arg3
The minimum value input on the EDPC command was zero, &
but the maximum value input was non-zero.  These values &
have been reset to minimum=1 and maximum=%I. 
/nopr
*endif
*endif


*if,arg2,eq,0.0,then
  arg2=arg1
*endif

*if,arg3,eq,0.0,then
  arg3=1.0
*endif

/gopr
*msg,info,arg1,arg2,arg3
Select and plot entities associated with contact. &
Range of contact definition numbers is  &
%I to %I in increments of %I.
/nopr


_prttocm=0

!If any of the contact currently defined is
!associated with parts, then components are
!made for each part below for subsequent 
!plotting with the cmplot command.
*do,_i,arg1,arg2,arg3
  *get,_key,edcc,_i,key
  *if,_key,eq,1.0,then 
     *if,_prttocm,eq,0.0,then
       PRTTOCMP 
       _prttocm=1
     *endif
  *elseif,_key,eq,2.0,then 
     *if,_prttocm,eq,0.0,then
       PRTTOCMP 
       _prttocm=1
     *endif
  *elseif,_key,eq,3.0,then 
     *if,_prttocm,eq,0.0,then
       PRTTOCMP 
       _prttocm=1
     *endif
  *endif
*enddo

*del,_prttocm
CMSEL,NONE
ESEL,NONE
NSEL,NONE


*do,_i,arg1,arg2,arg3
  
  *if,_i,le,_count,then

    *get,_key,edcc,_i,key
 
    *if,_key,eq,0.0,then
      *get,_comp,edcc,_i,comp,1
      CMSEL,A,_comp
      *get,_comp,edcc,_i,comp,2
      CMSEL,A,_comp
    *elseif,_key,eq,2.0,then
      *get,_comp,edcc,_i,comp,1
      CMSEL,A,_comp
      *get,_part,edcc,_i,part,2
      _comp='_PART%_part%'
      CMSEL,A,_comp
    *elseif,_key,eq,1.0,then
      *get,_part,edcc,_i,part,1
      _comp='_PART%_part%'
      CMSEL,A,_comp
      *get,_comp,edcc,_i,comp,2
      CMSEL,A,_comp
    *elseif,_key,eq,3.0,then
      *get,_part,edcc,_i,part,1
      _comp='_PART%_part%'
      CMSEL,A,_comp
      *get,_part,edcc,_i,part,2
      _comp='_PART%_part%'
      CMSEL,A,_comp
    *elseif,_key,eq,10.0,then
      _key10=1
    *endif

  *endif
      
*enddo


*if,_key10,eq,0,then

  *get,_j1,node,0,count
  *get,_j2,elem,0,count
  _j=_j1+_j2
  nsle,a
  CMPLOT
 
  *if,_j,eq,0,then
/gopr
*msg,warn
All elements and nodes were unselected by the EDPC command, but &
none were reselected.  
/nopr
  *endif

*elseif,_key10,eq,1,then
  esel,all
  nsel,s,ext
  nplot
*endif

/gopr
*msg,warn
The EDPC command alters the selected set of nodes and elements &
for display purposes. & 
Reselect the desired set of nodes and elements after EDPC. &
Reselection is always necessary before EDWRITE or SOLVE commands are &
issued.
