CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > ANSA

Ansa Script

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   November 28, 2013, 04:38
Default
  #21
New Member
 
Mihai Cris
Join Date: Nov 2013
Posts: 5
Rep Power: 2
mihaicris is on a distinguished road
Quote:
Originally Posted by vangelis View Post
Hi Mihai,

I suggest you place all your user scripts in a file named
ANSA_TRANSL...
Hello Vanghelis

Thank you for answering me.
What exactly should I write in this ANSA_TRANSL? Please do not forget I want to load python scripts.

For old bs scripts it should be somethig like:
#include "/path_to_script/myscript.bs"

How should it be for python, just writing #include "/path_to_script/myscript.py" does not work...


Cheers
mihaicris is offline   Reply With Quote

Old   November 28, 2013, 05:16
Default
  #22
Senior Member
 
Vangelis Skaperdas
Join Date: Mar 2009
Location: Thessaloniki, Greece
Posts: 157
Rep Power: 8
vangelis is on a distinguished road
Hello Mihai,

You are right, some clarifications for python scripts

1) The file must be called ANSA_TRANSL.py
2) In this file you must have entries like:

import ansa
ansa.ImportCode('/home/user/my_functions.py')
ansa.ImportCode('/home/user/my_functions2.py')
ansa.ImportCode('/home/user/my_functions3.py')

Vangelis
vangelis is offline   Reply With Quote

Old   November 28, 2013, 05:40
Default
  #23
New Member
 
Mihai Cris
Join Date: Nov 2013
Posts: 5
Rep Power: 2
mihaicris is on a distinguished road
Hello Vanghelis

Thank you again. I have the sensation that we are slowly converging to a solution. Just a few increments more...

So... if I include my scripts in the ANSA_TRANSL.py with the code you suggested:
- ANSA_TRANSL.py is loaded at ANSA start, shows up in Available modules section at Script>Run function
- none of the functions from "my_functions.py are" available, they do not appear in function list in the same dialog.

Just to eliminate a possible question, I can manually load my script without ANSA_TRANSL and run it, so it is a valid script.
mihaicris is offline   Reply With Quote

Old   November 28, 2013, 05:45
Default
  #24
Senior Member
 
Vangelis Skaperdas
Join Date: Mar 2009
Location: Thessaloniki, Greece
Posts: 157
Rep Power: 8
vangelis is on a distinguished road
Hello Mihai,

When you place your scripts in ANSA_TRANSL.py
and start ANSA, what are the messages reported
in the ANSA Info Window when ANSA starts?
Can you copy paste all messages?

Vangelis
vangelis is offline   Reply With Quote

Old   November 28, 2013, 06:16
Default
  #25
New Member
 
Mihai Cris
Join Date: Nov 2013
Posts: 5
Rep Power: 2
mihaicris is on a distinguished road
Hello Vanghelis


Error messages are... a lot of messages, but unimportant now, It is finally solved now.
With help from you and from the manual of course, it was there all along. Again! I do not know how I could miss it. Again!

So... for anybody else, if you have a file named say.. myLibrary.py importing all the functions from that file at ANSA start, using ANSA_TRANSL is done this way:

import ansa
ansa.ImportCode("/path_to_file/myLibrary.py")
from myLibrary import *


The last line appears in the ansa_python document as import myLibrary, it does not offer acces to the functions inside the file (at least in my case).
mihaicris is offline   Reply With Quote

Old   November 28, 2013, 07:39
Default
  #26
Senior Member
 
Vangelis Skaperdas
Join Date: Mar 2009
Location: Thessaloniki, Greece
Posts: 157
Rep Power: 8
vangelis is on a distinguished road
glad you've worked it out!
vangelis is offline   Reply With Quote

Old   April 8, 2014, 02:02
Default
  #27
New Member
 
sajun prasad
Join Date: Apr 2014
Posts: 4
Rep Power: 2
ANSA_User is on a distinguished road
Good Morning all,


can anyone kindly guide me for my question below please.


1. how to read excel file in ansa scripting( i want to import it and read it while executing it).



thank you very much for time taken to read it.
ANSA_User is offline   Reply With Quote

Old   April 8, 2014, 08:35
Default You can do that with python and pyxll library
  #28
New Member
 
Maries
Join Date: Mar 2010
Location: Chennai
Posts: 16
Rep Power: 6
rmaries is on a distinguished road
Quote:
Originally Posted by ANSA_User View Post
Good Morning all,


can anyone kindly guide me for my question below please.


1. how to read excel file in ansa scripting( i want to import it and read it while executing it).



thank you very much for time taken to read it.
Hi,

You can write the script using python. There is an external library pyxll(and many more are there), you can use it to open the excel file.

you can download the library here

https://www.pyxll.com
rmaries is offline   Reply With Quote

Old   April 8, 2014, 22:54
Default
  #29
New Member
 
sajun prasad
Join Date: Apr 2014
Posts: 4
Rep Power: 2
ANSA_User is on a distinguished road
hi maries,

thank you very much for your suggestion, but i would lik to know how to do it ANSA too.
ANSA_User is offline   Reply With Quote

Old   April 8, 2014, 23:37
Default
  #30
New Member
 
Maries
Join Date: Mar 2010
Location: Chennai
Posts: 16
Rep Power: 6
rmaries is on a distinguished road
Quote:
Originally Posted by ANSA_User View Post
hi maries,

thank you very much for your suggestion, but i would lik to know hot to do it ANSA too.
You can run the python script in ANSA. Can you give an example sheet and give the example sheet. If i have time i will try

Regards
Maries
rmaries is offline   Reply With Quote

Old   April 8, 2014, 23:52
Default
  #31
New Member
 
sajun prasad
Join Date: Apr 2014
Posts: 4
Rep Power: 2
ANSA_User is on a distinguished road
Good morning Maries ,

Currently i am working in Beta script and have to execute that in ANSA. I ll check that and i will come back to you.actually i m kinda new to scripting so may take time.

Warm regards
Sajun
ANSA_User is offline   Reply With Quote

Old   April 8, 2014, 23:56
Default
  #32
New Member
 
Maries
Join Date: Mar 2010
Location: Chennai
Posts: 16
Rep Power: 6
rmaries is on a distinguished road
Quote:
Originally Posted by ANSA_User View Post
Good morning Maries ,

Currently i am working in Beta script and have to execute that in ANSA. I ll check that and i will come back to you.actually i m kinda new to scripting so may take time.

Warm regards
Sajun
If you are using ANSA version > 14. Better do your scripting in python. You can find lot of materials and libraries available in internet for python.

Ansa version < 14 doesn't support python scripting. You can do scripting only in Beta script.

Thanks & Regards
Maries
rmaries is offline   Reply With Quote

Old   April 15, 2014, 06:56
Default
  #33
New Member
 
sajun prasad
Join Date: Apr 2014
Posts: 4
Rep Power: 2
ANSA_User is on a distinguished road
hi maries,

there is a inbuilt function in ANSA itself ,to read and access the excel file. anyways thanks for your help.

Regards
sajun
ANSA_User is offline   Reply With Quote

Old   May 6, 2014, 03:37
Exclamation ansa scripting
  #34
New Member
 
Bharat
Join Date: Oct 2011
Posts: 1
Rep Power: 0
sbharatk is on a distinguished road
I am a new and just started scripting in ANSA_v15.
1. If I have to add Menu button just next to "File, Window, Containers, Tools, MyMenu, Utilities, Assembly, Help". How can I add?
2. How to attach a script in User Button Script window?
3. If I create "User Menu" from Settings>Buttons Manager > Create Menu, do we attach script to it?
4. Where to see available APIs to call functionality from ANSA?

B.

Last edited by sbharatk; May 6, 2014 at 05:30.
sbharatk is offline   Reply With Quote

Old   May 25, 2014, 03:29
Default Storing XML connection data
  #35
New Member
 
Ganesh
Join Date: Jan 2013
Posts: 6
Rep Power: 3
ganesh0481 is on a distinguished road
Hi All,

I used Read connections command for reading connection file. I like to store the information after reading the data.
e.g : dia, x.y.z

let me know if anyone has some method on the same.

Thanks
Ganesh
ganesh0481 is offline   Reply With Quote

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
CentFOAM Python Script Installation: Error socon009 OpenFOAM Installation 2 May 26, 2012 09:36
[ICEM] Script: problems with face names Maweil ANSYS Meshing & Geometry 2 October 25, 2011 21:32
ANSA hexblock mesh to OpenFOAM yosuu OpenFOAM Other Meshers: ICEM, Star, Ansys, Pointwise, GridPro, Ansa, ... 7 October 22, 2011 06:18
Output deck from ANSA for OpenFOAM use Kattie OpenFOAM Meshing & Mesh Conversion 10 February 2, 2011 07:46
Perl script for intialisation pratik mehta CFX 2 September 10, 2008 03:09


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