CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   ANSA (https://www.cfd-online.com/Forums/ansa/)
-   -   Ansa batch mode for already running ansa window (https://www.cfd-online.com/Forums/ansa/204389-ansa-batch-mode-already-running-ansa-window.html)

Viswa July 22, 2018 08:26

Ansa batch mode for already running ansa window
 
Dear all,

I am using ansa batch comand to open and load script

Example:
Ansa.exe -i file name -loadscript scriptname

The above comand will open new ansa load file and run script.

My requirement is i already opened ansa. Files should load on that.

Example:
Already openned ansa process id -i file name -loadscript file name.

How to do this?

rmaries July 23, 2018 02:18

Quote:

Originally Posted by Viswa (Post 700054)
Dear all,

I am using ansa batch comand to open and load script

Example:
Ansa.exe -i file name -loadscript scriptname

The above comand will open new ansa load file and run script.

My requirement is i already opened ansa. Files should load on that.

Example:
Already openned ansa process id -i file name -loadscript file name.

How to do this?

From which program do you want to call Ansa. Is it batch or something else?

This is called interprocess communication in programming. I am this using program called autoit. I assume one can do the same thing with any other programming language also. I am also very much interested in this topic.

Viswa July 25, 2018 13:16

hi rmaries,

i try to call ansa by batch file or by python.
if you know anyother language or process to acheive this , that is fine. i will learn that.
if i can controll arlerady opened program by another tool, it will be help me very much.

rmaries July 26, 2018 04:24

I am doing an inefficient way as of now to achieve this. Sending keypress to ansa window. If ansa window is active and someone is typing in keyboard, all the pressed keys are appeared in search function and filter. So to open a ansa file, one can type
Code:

File : Open recent: C:\Ansa\ansa_file.ansa
After that you can you need to call the script again like this.
Code:

User: Load_script(script path)
So any program which send keypress to other process will work for this. I am using AutoIt. As I said earlier, it is an inefficient process. Limitation is when the program is sending keypress, if the user press the keyboard by mistake this won't work.

Efficient way it use other proved methods like

Pipes
Memory mapped files
RPC(remote procedure call) I prefer this. I need to learn how to do that with python. There is a separate library called xmlrpc for this. With this we can make ansa to work like server waiting for command from other process. Also need to learn multiprocessing in python for this. You can go through other methods in python docs https://docs.python.org/3/library/ipc.html

If possible share your code in git.

Thanks

Viswa July 26, 2018 08:54

Thank you. i will check it and inform you.

ujjwalmohanty May 21, 2020 15:08

Quote:

Originally Posted by Viswa (Post 700054)
Dear all,

I am using ansa batch comand to open and load script

Example:
Ansa.exe -i file name -loadscript scriptname

The above comand will open new ansa load file and run script.

My requirement is i already opened ansa. Files should load on that.

Example:
Already openned ansa process id -i file name -loadscript file name.

How to do this?






Hi Viswa,


How did you manage to launch Ansa?

I tried using the Popen function in Python, but I get a fatal error and the window closes.
I tried Popen('location/ansa64.bat').


Could you please help?


All times are GMT -4. The time now is 04:31.