XANSYS Message: 40955 [Go back to message list]
No rating yet
Rate item:

Subject: Re: (None) tcl/tk question
Author: Karen Loiselet
Date: 2002-08-21 02:53:00

Hi
You can make a stand alone executable ".exe" file of a tcl script with
freewrap, it's a freeware.
Karen

dyne design engineering gmbh
muhlestrasse 13
5702 niederlenz
switzerland
t +41.62.892 8650
f +41.62.892 8651
mailto:karen.loiselet@d...
www.dyne.ch

-----Ursprungliche Nachricht-----
Von: Matt Sutton [mailto:matt.sutton@p...]
Gesendet: Dienstag, 20. August 2002 17:51
An: 'xansys@yahoogroups.com'
Betreff: RE: [xansys] Re: (None) tcl/tk question

Hi Thanh,
I think Ashok has pointed you down the right path, but there are a
couple of things I would like to add. First, remember that tcl is an
interpreted language, so it won't actually generate a stand alone executable
(*.exe). It's not a big deal, you just have to make sure your users have a
separate tcl interpreter installed on there machine. Second, something that
might easy your programming is if instead of having your tcl code write out
the full ANSYS input file, or even having it modify an existing input file,
just have it write out the parameter definitions to a file with a
predetermined name. Ask tcl to save that file in you solution working
directory. Then, in your ANSYS input file, code this predetermined filename
one time by hand into a /inp command. This way you don't have to worry
about parsing through your macro, inadvertently stepping on code, etc...
Good luck,
Matt
PADT

-----Original Message-----
Sent: Monday, August 19, 2002 9:11 PM
To: xansys@yahoogroups.com

Hi,

Your situation is a bit more clearer now ...
Two approaches I can think of:

1. Prepare a template file for your problem in APDL ( as Matt suggested).
Then have your Tcl code get the user
input and plug in the correct values into the macro. Better still you can
simply write out the whole APDL macro
from Tcl to a temporary file and then read it into Ansys.
Then use the 'exec' command in Tcl to start of an Ansys batch run. Refer
the documentation for the exact
command line parameters. But roughly it would look something like
/ansys_inc/ansys60/bin/ansys60 -p -j -m required> -b < yourfile.inp

The '-b' indicates ansys is to run in batch mode and 'yourfile.inp' is the
APDL macro that you generated for
your problem.

2. You can use a server-client approach to have your Tcl application
control Ansys by sending appropriate
APDL commands. So lets say you have a Tcl application running within Ansys
that can recieve commands (and pass
it on into Ansys) ... and then there is your Tcl application that sends
commands.
Look into the /ansys60/lib/scripts/AnsServer.tcl file for a sample
implementation of this concept.

If your user need not be aware of Ansys and should still be able to work, I
guess Approach 1 above would work.
Ansys runs quitely in the background and writes out the results.

Now I am not sure what you mean by allowing the user to 'preview' the
boundary conditions. If you mean you are
going to create some kind of graphical display within your Tcl application
then good luck !!

Or if you would just like to use the Ansys Graphics window for these
displays then Approach 2 above would
probably be better. (but then there is the hassle of having to start your
application, the ansys application
and then the server within Ansys before everything works)

Ashok
EACoE, Bangalore

daines9478 wrote:

> Thanks, guys for answering my question. I really appreciate that you
> took your time.
> I want to explain my problem a little more clear because it seems
> that both of you suggest that I should run this w/in Ansys, which is
> not what I want. (I hope I did not offend you if I misunderstood
> you).
> I want to explain my problem in Today's process & Tomorrow's process:

> Today's process:
> I have built parametric files and ran it w/ difference parameters .
> Being a user of Ansys, these are the following step that I usually
> take to run my apdl file.
> 1) Look for my parametric file, & change the parameters at the
> approriate lines.
> 2) I have to click on the Ansysbatch.exe to activate Ansys batch
> 3) Fill in the appropriate file name, input file name, output file
> name
> 4) "Run"
> 5) Retrieve the JPEG file, or Lis file & graph this in Excel (These
> are the step that can be setup in the APDL file)

> Tomorrow's process
> Let's say I want to built a box w/ some heat flux applied at the top
> and a fix temperature at the bottom.
> 1) My user click on MyHeaterBox.exe,or MyFinHeatsink.exe (depending
> on the Tcl program that I had written)
> 2) a window will appear asking " Fill in lenght, width, height, Heat
> Flux, Bottom Temperature".
> 3) Hit on the preview button, the user will see the box w/ the
> appropriate boundary conditions.
> 5) Hit "Run". This is when MyHeaterBox.exe start the process 1 to 5
> of the Today's process.

> My users will not have to know Ansys. They just have to answer the
> strict questions that I had set out in my Tcl/parametric file. Of
> course, if they a different configuration, the Ansys guy will have to
> create an all new program for it.

> Thanks for you help. Meanwhile, I will check out Sheldon's website.

> Thanh Tran
> Design Engineer
> International Rectifier
> El Segundo, CA

> --- In xansys@y..., Matt Sutton wrote:
> > Hi Thanh,
> > I have done some tcl programming in ANSYS on occasion and I
> would be
> > happy to provide assistance if needed. I would say that Ashok is
> correct in
> > that the two most common commands to tie tcl code to ANSYS are
> > ans_sendcommand and ans_getvalue because these two commands form a
> two way
> > pipe that enables you to ask ANSYS to do something
> (ans_sendcommand) or ask
> > ANSYS something about the current state of the model
> (ans_getvalue). From
> > the general description of your problem given below, I would
> recommend, if
> > you haven't done so already, that you completely code the
> parametric input
> > file first in APDL without worrying about tcl. Try and generalize
> the
> > script by factoring out all of the possible variations into a set
> of APDL
> > parameters. The reason this is important is because in the end,
> whether you
> > are writing an external command in C/C++ or writing tcl code as in
> your
> > case, you always drive ANSYS through the APDL command interpreter.
> It just
> > so happens that for tcl programs in ANSYS, the hooks into the
> command
> > interpreter are the ans_* set of functions. By creating a robust
> APDL
> > script first, at a minimum you will have a template of what you will
> > eventually code in tcl using the ans_* functions, or more likely,
> you will
> > have the "engine" for your app completely coded, and all the tcl
> code will
> > have to do is ask the user for some values and then stick those
> values into
> > the APDL parameters defined within your script. Perhaps your at
> this point
> > already, and your question simply revolves around setting
> parameters within
> > ANSYS. If so, here are a few lines of tcl code you can type into
> the
> > command window in ANSYS to get a small feel for how you can move
> data into
> > ANSYS from tcl and out of ANSYS into tcl.

> > ! This code will set the ANSYS parameter my_param
> > ! to 1 using the tcl interpreter. (Same as my_param=1 in APDL)
> > ~eui, 'ans_sendcommand *set,my_param,1'
> > ! After executing this command, list your parameters
> > ! to see if a parameter named my_param has been
> > ! defined.

> > ! This code will extract the value of an ANSYS parameter
> > ! and store it in a tcl variable so that you can
> > ! operate on it with tcl.
> > ~eui, 'set tcl_var [ans_getvalue PARM,my_param,VALUE]'
> > ! The tcl function ans_getvalue is analogous to the *get
> > ! APDL function. The argument to this function is a string
> > ! consisting of fields three through eight of the *get command.

> > ! This code will print the value stored in the tcl variable
> > ! tcl_var to the output window.
> > ~eui, 'puts "The value of tcl_var is: $tcl_var"'

> > Matt
> > PADT

> > -----Original Message-----
> > From: Ashok [mailto:ashok.ka@g...]
> > Sent: Monday, August 19, 2002 2:09 AM
> > To: xansys@y...
> > Subject: Re: [xansys] (None) tcl/tk question

> > Hi,

> > The missing link ?

> > 1. You have to run your Tcl/Tk code from within Ansys using the ~eui
> > command. If you tried the "simple.tk" example on the PADT inc
> website,
> > then you probably got this right already.

> > 2. Use the Tcl commands provided by Ansys for interacting wtih the
> Ansys
> > executable.

> > 3. The command "ans_sendcommand" is probably the most used. You just
> > call this command and give any APDL command as its argument and it
> gets
> > executed in Ansys.

> > 4. The command "ans_getvalue" makes a call to *GET in APDL and
> returns
> > what the *GET would have returned.

> > 5. You can look in Sheldon's website http://www.ansys.net for some
> > additional documents on the available Tcl commands.

> > Hope that helps you get started ...

> > Thanks,
> > Ashok
> > EACoE, Bangalore

> > daines9478 wrote:

> > > Hi guys,
> > > I want to creat small(?) software for my company that has many
> none-
> > > ansys user. Basically, the user will fill in a certain parameter
> in
> > > my program. As they hit the "Run" button, the program will start
> > > accessing Ansys, run a parametric file then spit back to the
> program
> > > the value or graph that was generated in Ansys from that
> parametric
> > > file. The user will not have to know Ansys but they will have to
> > > follow the STRICT user interface that I had create (which will
> creat
> > > that parametric file). I hope I had been cleared enough. I think
> > > somebody must have done this.

> > > Anyway, some of the tech support people had suggested me to look
> at
> > > Tcl/Tk as a programable language. I had tried the Tcl/Tk example
> > > from PAD inc website. Spoke to Eric about some problem on the
> > > example. Bought a book on Tcl/Tk, glanced over it. The missing
> > > linking for me is the link from Tcl/Tk into Ansys. Has anybody
> ever
> > > tried out this idea/problem ? A simple example would be very
> > > helpful. Thanks for your help

> > > Thanh Tran
> > > Design Engineer
> > > International Rectifier
> > > El Segundo, CA


Posts possibly associated with message #40955AuthorDateScore
40882(None) tcl/tk questionThanh Tran2002/08/19 
40883Re: (None) tcl/tk questionAshok2002/08/19 
40897Re: (None) tcl/tk questionMatt Sutton2002/08/190
40910Re: (None) tcl/tk questionThanh Tran2002/08/190
40912Re: (None) tcl/tk questionAshok2002/08/20 
40932Re: (None) tcl/tk questionMatt Sutton2002/08/20 
40936Re: (None) tcl/tk questionThanh Tran2002/08/20 
40955Re: (None) tcl/tk questionKaren Loiselet2002/08/21