CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   ANSA (https://www.cfd-online.com/Forums/ansa/)
-   -   Ansa Python Scripting (https://www.cfd-online.com/Forums/ansa/192101-ansa-python-scripting.html)

Renu123 August 28, 2017 09:29

Ansa Python Scripting
 
Hi all,
1. I want to read .ansa files contain in some directory, How I do that using python script?
using following function I am able to read only current file which is open in ansa gui
base.GetEntity(ansa.constants.NASTRAN, "PSHELL", 1)
Looking for function that able to read all file at ones.


2. I am also looking for function that gives normal to surface.


Thank you:)

rmaries August 29, 2017 03:06

Ansa python scripting
 
1 Attachment(s)
Hi Renuka,

You can open ansa file with the command

base.open(filename)

Open, BETA PYTHON development Manual
NAME:
Open - Opens an existing file in ANSA.

SYNOPSIS:
ansa.base.Open(filename)

DESCRIPTION:
This function instructs ANSA to open an existing file.
Arguments

filename


RETURN:
It returns 0 in case of success or 0:OPEN_ANSA_FILE_SUCCESS, 1:OPEN_ANSA_FILE_PERMISSION_DENIED,
2:OPEN_ANSA_FILE_NOT_ANSA_DB, 3:OPEN_ANSA_FILE_NOT_VALID_CAD, 4:OPEN_ANSA_FILE_NOT_COMPATIBLE_DB,
5:OPEN_ANSA_FILE_READ_ERROR, 6:OPEN_ANSA_FILE_CAD_ERROR, 7:OPEN_ANSA_FILE_NOT_ALLOWED_IN_THIS_MODULE

EXAMPLE:
import ansa
from ansa import base


def main():

base.Open("C:/tmp/users/folder/data.ansa")


I attached the screenshot of the script window. You can search for the ansa script command or function in the right side of your script window.

You can learn ansa scripting by seeing the already available ansa scripts in ansa installation folder. You can source code of the user scripts in below folder BetaCAE\ansa_v17.1.2\scripts. You should know python and ansa to do scripting. Without having experience in ansa, scripting is going to be very difficult for you. :)

Regards
Maries

Quote:

Originally Posted by Renu123 (Post 662155)
Hi all,
1. I want to read .ansa files contain in some directory, How I do that using python script?
using following function I am able to read only current file which is open in ansa gui
base.GetEntity(ansa.constants.NASTRAN, "PSHELL", 1)
Looking for function that able to read all file at ones.


2. I am also looking for function that gives normal to surface.


Thank you:)


Renu123 August 29, 2017 03:46

Quote:

Originally Posted by rmaries (Post 662214)
Hi Renuka,

You can open ansa file with the command

base.open(filename)

Open, BETA PYTHON development Manual
NAME:
Open - Opens an existing file in ANSA.

SYNOPSIS:
ansa.base.Open(filename)

DESCRIPTION:
This function instructs ANSA to open an existing file.
Arguments

filename


RETURN:
It returns 0 in case of success or 0:OPEN_ANSA_FILE_SUCCESS, 1:OPEN_ANSA_FILE_PERMISSION_DENIED,
2:OPEN_ANSA_FILE_NOT_ANSA_DB, 3:OPEN_ANSA_FILE_NOT_VALID_CAD, 4:OPEN_ANSA_FILE_NOT_COMPATIBLE_DB,
5:OPEN_ANSA_FILE_READ_ERROR, 6:OPEN_ANSA_FILE_CAD_ERROR, 7:OPEN_ANSA_FILE_NOT_ALLOWED_IN_THIS_MODULE

EXAMPLE:
import ansa
from ansa import base


def main():

base.Open("C:/tmp/users/folder/data.ansa")


I attached the screenshot of the script window. You can search for the ansa script command or function in the right side of your script window.

You can learn ansa scripting by seeing the already available ansa scripts in ansa installation folder. You can source code of the user scripts in below folder BetaCAE\ansa_v17.1.2\scripts. You should know python and ansa to do scripting. Without having experience in ansa, scripting is going to be very difficult for you. :)

Regards
Maries

Thank you for reply I will check it.:)


All times are GMT -4. The time now is 23:46.