! ******************************
! $Revision: 145002 $
! $Date: 2009-11-13 11:20:27 -0500 (Fri, 13 Nov 2009) $
! ******************************
! macro MTbodyld (_csnum,_type,_xval,_yval,_zval)

! *** primary function: fills the volume loading array (plane #4)

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

!  input arguments:
!   _csnum     (arg1)    (int,sc)      the coordinate system reference number
!                                        0=cartesian, 1=cylin,  2=spher,  3=toroidal
!   _type      (arg2)    (char*8,sc)   load type:
!                                        ACEL  - acceleration 
!                                        OMEG  - rotational velocity
!                                        TEMP  - uniform temperature
!  _xval       (arg3)    (dp,sc)       value in x-direction
!  _yval       (arg4)    (dp,sc)       value in y-direction
!  _zval       (arg5)    (dp,sc)       value in z-direction

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

!  modified parameters:
!   %_ACTENV%            (array)       load array corresponding to the active environment

/nopr
! --- debug
*if,_DEBUG,gt,0,then
!{
   /gopr
   *if,_DEBUG,lt,3,then
   !{
      /nopr
   !}
   *endif
!}
*endif
_csnum=arg1
_lab=UPCASE(arg2)
_xval=arg3
_yval=arg4
_zval=arg5

_ACTENV='_ENV%_CURENV%'
 
!  transfer values from specified csys to global if required
*if,_csnum,ne,0,then 
  *dim,_invect,,1,3
  *dim,_outvect,,1,3
  _invect(1,1)=_xval
  _invect(1,2)=_yval
  _invect(1,3)=_zval
  *get,_ucsys,active,,csys !to allow restore of user's active csys 
  cswpla,101,0,1,1         !dummy csys to restore workplane to
  *if,_csnum,ne,4,then
    wpcsys,-1,_csnum        !align workplane w/ force csys
  *endif
  csys,0                   !next two lines offset workplane to global
  wpave,0,0,0              !origin but retains rotations
  cswpla,102,0,1,1         !align csys102 with workplane 
  *vfun,_outvect(1,1),global,_invect(1,1),102 !uses _csnum but translated
                                           !to global origin  
  csys,_ucsys              !restore users active csys
  wpcsys,-1,101            !restore users workplane
  wpstyle,,, ,,, ,,0       !turn off the working plane
  csdele,101
  csdele,102
  _xval=_outvect(1,1)
  _yval=_outvect(1,2)
  _zval=_outvect(1,3)
  *del,_invect
  *del,_outvect
  _ucsys=
*endif

*if,_lab,eq,'ACEL',then  

  %_ACTENV%(1,2,4)=_xval
  %_ACTENV%(1,3,4)=_yval
  %_ACTENV%(1,4,4)=_zval

  ! APPLY SYMBOLS
  acel,_xval,_yval,_zval
  
*elseif,_lab,eq,'OMEG',then

  %_ACTENV%(1,10,4)=_xval
  %_ACTENV%(1,11,4)=_yval
  %_ACTENV%(1,12,4)=_zval

  ! APPLY SYMBOLS
  omega,_xval,_yval,_zval
  
*elseif,_lab,eq,'TEMP',then

  %_ACTENV%(1,5,4)=_xval
  %_ACTENV%(1,6,4)=_yval

  ! APPLY SYMBOLS
  bfunif,temp,_xval
  tref,_yval

*else
  *msg,ui,_lab
  Load label %C not recognized in MTbodyld

*endif  !end of testing _lab

_csnum=
_lab=
_xval=
_yval=
_zval=
