!
!       TITLE:  mkmac.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!               Rev -     02/28/2001    D. Edwards
!               Rev A     04/13/2001    D. Edwards
!                 Operate on the selected line set instead of all
!                 lines and KP's in the database.
!
!              Rev B   05/11/2002      D. Edwards
!                       Use ActiveState PerlApp to make mkmac.perl and
!                       getinfo.perl into stand alone .exe files for the
!                       Windows platform
!---------------------------------------------------------------------------
!
! Make a new macro from the currently selected set of lines.
!
! Macro information is obtained through prompting in the Ansys Output
! window.  All the information to fill in the macro template and parm
! template files is prompted for.
!
! The resulting macro is written to the Ansys working directory.
!
! Keypoints are created at the center of each arc, if there are any.
!
!  NOTE:  This macro requires perl to be installed on the computer.
!         See ansys/tools/README.perl for more information.
!
!------------------------------ COMMAND SYNTAX -----------------------------
!
! USAGE:  mkmac,'fname'
!         mkmac                  (All prompted input)
!
!   where fname = base file name (w/o extension) of temporary
!                 files to create while making the macro.
!
!------------------------------ Examples -----------------------------------
!
! Prompt for information needed to fill in the new macro and store it
! in flange.inf.
!
!   getiges 'flange'
!
! Running the command again will use the contents of flange.inf rather than
! prompt for all the same information again.  Any changes to the information
! is accomplished by editing flange.inf before rerunning the getiges macro.
!
!---------------------- List of Dependencies ------------------------------
!
!   mkmac.mac
!       tools/getinfo.perl
!       tools/mkmac.perl
!           tools/macro_template.mac
!           tools/parameter_file_template.parm
!           fname.inf
!           fname.des.inf  (optional)
!           kp_def.lis
!           kp_cent.lis
!           l_def.lis
!
!---------------------------------------------------------------------------

*get,prkey_,active,0,prkey
/nopr

! Prompt for base name if not given on command line
fname_=arg1
*get,ptype_,parm,fname_,type
*if,ptype_,ne,3,then
    *ask,fname_,Enter the base name of the .igs file:,'new_mac'
*endif

fini

/prep7

ksll,s

! This is optional and can be commented out without causing problems
numcmp,all

! Create a KP at the center of each arc
*get,lmin_,LINE,0,num,min
*get,lmax_,LINE,0,num,max

*do,i_,lmin_,lmax_
  *if,lsel(i_),eq,1,then
    *get,len_,LINE,i_,leng
    *get,kp1_,LINE,i_,kp,1
    *get,kp2_,LINE,i_,kp,2

    *if,len_,gt,distkp(kp1_,kp2_),then
      kcenter,line,i_
    *endif

  *endif
*enddo

! Generate KP listing
/out,kp_def,lis
klist,all,,,coord
/out

! Generate LINE listing
/out,l_def,lis
llist,,,,radius
/out

! Generate list of KP's at arc centers
ksll,u
/out,kp_cent,lis
klist,all,,,coord
/out

/pnum,kp,1
/pnum,line,1
lplot

! Generate an Ansys macro from the KP and line information
/syp,runperl.bat getinfo.perl,fname_
/syp,runperl.bat mkmac.perl,fname_


!
! Debugging lines (normally commented out)
!

! See which perl is in use
!/sys,perl -v

! Work
!/sys,perl -d e:\sl\ansys\dee\getinfo.perl test1

! Home
!/sys,perl -d j:\eng\ansys\dee\getinfo.perl 'test1'
!/sys,perl -d j:\eng\ansys\dee\mkmac\mkmac.perl 'fred'


*if,prkey_,eq,1,then
    /go
*endif