CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   ANSA (https://www.cfd-online.com/Forums/ansa/)
-   -   ANSA version convert (https://www.cfd-online.com/Forums/ansa/225296-ansa-version-convert.html)

sumpate March 22, 2020 07:38

ANSA version convert
 
Hello all,
Using script how to convert ansa version ..e.g. from ansa 18 to ansa 17 ?
I don't want to open ansa gui

rmaries March 23, 2020 00:27

Quote:

Originally Posted by sumpate (Post 762447)
Hello all,
Using script how to convert ansa version ..e.g. from ansa 18 to ansa 17 ?
I don't want to open ansa gui

Use the below command, write an ansa script and run it in batch mode

SaveAs, BETA PYTHON development Manual
NAME:
SaveAs - Saves the current file with a new filename.

SYNOPSIS:
ansa.base.SaveAs(filename, version, silent) Named Arguments

DESCRIPTION:
This function saves the current file in ANSA with a new filename.
Arguments

filename string The name of the new file with which the current
file is going to be saved must contain the full
pathname.
version string (optional) Valid values are 'v17' and 'previous'.
silent boolean (optional) If set to True the active database path will not
be updated to the pathname given. False by default.
The version argument takes precedence and overrides the silent argument.

stefat February 3, 2022 06:50

Hello everyone!

I was trying myself to make a script based on the Manual but unfortunatly i dont have enough knowledge in Python to solve this problem.

My script looks like this now:

Quote:

# PYTHON script
import os
import ansa
from ansa import base

def inp_filename(): #

inpf = open(sys.argv[1],'r')

def out_filename(): #
#
inpf = open(sys.argv[1],'r') # The script use the first command line argument as input file name
outf = open(sys.argv[1][0:-5] + '_21.ansa', 'w') # Open a file with same name and postfix

# inpf.close()

def main():
base.Open(inpf)
base.SaveAs(outf, previous)
Ofc it's not working.

Is there someone who can fix it for me? Or make a brand new one witch works in batch mode to convert a existing ansa file to convert it to previous version?

Thanks in advance!


All times are GMT -4. The time now is 01:39.