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

! *** primary function: define a new coordinate system based on the current WP

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

!  input arguments:
!   _type      (arg1)    (int,sc)      coordinate system type:
!                                        0 - cartesian
!                                        1 - cylindrical
!                                        2 - spherical
!   _MTNAME    (global)  (char*8,ar(4)) the name of the new environment

!  output arguments:
!   _success            (int,sc)      =0 no success, =1 success  


/nopr
_SUCCESS=1

! --- debug
*if,_DEBUG,gt,0,then
!{
   /gopr
   *vwrite,arg1
   (' === MTcsys:     cs type =',f3.0)
   *if,_DEBUG,lt,3,then
   !{
      /nopr
   !}
   *endif
!}
*endif

! --- check arguments
_type = ARG1
_type=0              !!! type not passed in for now (needs to go on dialog)
*if,_type,lt,0,then
!{
   *msg,error,_type
   MTcsys error: The cs type is %i
   _SUCCESS=0
!}
*elseif,_type,gt,2,then
!{
   *msg,error,_type
   MTcsys error: The cs type is %i
   _SUCCESS=0
!}
*endif

! call to add the appropriate load
*if,_SUCCESS,gt,0,then
!{

! load the name
_CSNAM(_NXTCS,1) = _MTNAME(1)
_CSNAM(_NXTCS,2) = _MTNAME(2)
_CSNAM(_NXTCS,3) = _MTNAME(3)
_CSNAM(_NXTCS,4) = _MTNAME(4)
_CSDP(_NXTCS) = 1             ! do not allow delete: this could screw up BC application

! define the cs by aligning it with the working plane
cswp,_NXTCS,_type

! set the global picked location
_CURCS = _NXTCS

! update the counters
_NXTCS = _NXTCS + 1
_NUMCS = _NUMCS + 1

! turn off the working plane - unfortunately no way to turn off widget!
! this is now done in the mtload macros (since wpave turns it back on!)

_SUCCESS=0
!}
*endif

*if,_DEBUG,gt,0,then
!{
   /gopr
   /com, === leave MTcsys:
   _name1 = _CSNAM(_CURCS,1)
   _name2 = _CSNAM(_CURCS,2)
   _name3 = _CSNAM(_CURCS,3)
   _name4 = _CSNAM(_CURCS,4)
   *vwrite,_CURCS,_name1,_name2,_name3,_name4
   ('   cs number=',f3.0,'    name=',4a)
   cslist,_CURCS
   *del,_name1
   *del,_name2
   *del,_name3
   *del,_name4
!}
*endif

! delete local variables
*del,_type
*del,_size
