! ******************************
! $Revision: 145002 $
! $Date: 2009-11-13 11:20:27 -0500 (Fri, 13 Nov 2009) $
! ******************************
! macro MTshpadd (_shaploc,_thick)

! *** primary function: add a new shape to the shape data structure

! *** Notice - This file contains ANSYS Confidential information ***

!  input arguments: 
!   _shaploc   (arg1)    (int,sc)      the picked location in the shape list
!   _thick     (arg2)    (dp,sc)       the thickness value
!   _MTNAME    (global)  (char*8,ar(4)) the name of the new shape

!  modified parameters:
!   xxxx            (array)

/nopr
_SUCCESS=1

*if,_DEBUG,gt,0,then
!{
   /gopr
   *vwrite,arg1,arg2
   (' === MTshpadd:'/'    shaploc =',f3.0,'   thick=',g12.4)
   *if,_DEBUG,lt,3,then
   !{
      /nopr
   !}
   *endif
!}
*endif

_shaploc = ARG1
*if,_shaploc,lt,0,then
!{
   *msg,error,_shaploc
   MTshpadd error: The picked location in the list is %i
   _SUCCESS=0
!}
*elseif,_shaploc,gt,_MAXSHAP,then
!{
   *msg,error,_shaploc,_MAXSHAP
   MTshpadd error: The picked location in the list is %i which is greater &
   than MAXSHAP
   _SUCCESS=0
!}
*endif

*if,_MTNAME(1),eq,'        ',then
!{
   *msg,error
   MTshpadd error: The shape name is blank
   _SUCCESS=0
!}
*endif

_thick = ARG2
*if,_thick,le,0,then
!{
   *msg,error,_thick
   MTshpadd error: The thickness is %G
   _SUCCESS=0
!}
*endif

! define the new shape using the information from the picked one
*if,_SUCCESS,gt,0,then
!{

_SHAPNAM(_NXTSHAP,1) = _MTNAME(1)
_SHAPNAM(_NXTSHAP,2) = _MTNAME(2)
_SHAPNAM(_NXTSHAP,3) = _MTNAME(3)
_SHAPNAM(_NXTSHAP,4) = _MTNAME(4)

_SHAPTYP(_NXTSHAP) = _SHAPTYP(_shaploc)

_SHAPCMD(_NXTSHAP,1)='euidl::s'
_SHAPCMD(_NXTSHAP,2)='etElemen'
_SHAPCMD(_NXTSHAP,3)='tType   '
_SHAPCMD(_NXTSHAP,4)='        '

_SHAPDP(_NXTSHAP,1) = _SHAPDP(_shaploc,1)         ! same type as picked element
_SHAPDP(_NXTSHAP,2) = _NXTREAL
_SHAPDP(_NXTSHAP,3) = 2                           ! allow delete

_SHAPET(_NXTSHAP,1) = _SHAPET(_shaploc,1)
_SHAPET(_NXTSHAP,2) = _SHAPET(_shaploc,2)

! add the thickness
r,_NXTREAL,_thick

! set the REAL pointer
real,_NXTREAL

! set the global picked location
_CURSHAP = _NXTSHAP

! set this as the default shape
mtshpcpy

! update the counters
_NXTSHAP = _NXTSHAP + 1
_NUMSHAP = _NUMSHAP + 1
_NXTREAL = _NXTREAL + 1

*if,_DEBUG,gt,1,then
!{
   /gopr
   /com, === leave MTshpadd:
   _n = _NXTSHAP - 1
   _shtyp = _SHAPTYP(_n)
   _cmd1 = _SHAPNAM(_n,1)
   _cmd2 = _SHAPNAM(_n,2)
   _cmd3 = _SHAPNAM(_n,3)
   _cmd4 = _SHAPNAM(_n,1)
   _type = _SHAPDP(_n,1)
   _real = _SHAPDP(_n,2)
   _flag = _SHAPDP(_n,3)
   *vwrite,_n,_shtyp,_cmd1,_cmd2,_cmd3,_cmd4
   ('   location=',f3.0,'   shape type=',a/'    name=',4a)
   _cmd1 = _SHAPCMD(_n,1)
   _cmd2 = _SHAPCMD(_n,2)
   _cmd3 = _SHAPCMD(_n,3)
   _cmd4 = _SHAPCMD(_n,1)
   *vwrite,_cmd1,_cmd2,_cmd3,_cmd4
   ('   euidl command=',4a)
   *vwrite,_type,_real,_flag
   ('   TYPE=',f3.0,'  REAL=',f3.0,'   show flag=',f3.0)
   rlist,_NXTREAL-1
   *if,_DEBUG,eq,5,then
      !{
      mtdumpsh                       ! dump out the entire data structure
      !}
   *endif
   *del,_n
   *del,_shtyp
   *del,_cmd1
   *del,_cmd2
   *del,_cmd3
   *del,_cmd4
!}
*endif

!}
*endif

! delete local variables
*del,_shaploc
*del,_thick
