-
-
July 27, 2023 at 8:49 am
Tomasz Walkowiak
SubscriberHi all,
I'm working on a Harmonic Response analysis.
My calculations are set up in a way that I have multiple analysis systems, like in the picture below:Results I'm interested in are the frequency responses for the stresses at the specific nodes:
In total I have 216 results which I would like to export to separate .txt files.
I can do it manually for each result, but it takes a lot of time, so the best option is to write a Python script.
The simple script I made looks like this:
When I run the script I get the following error message:Is there any other way of exporting the frequency and amplitude data for the selected results? -
July 27, 2023 at 4:32 pm
Aniket Chavan
Forum ModeratorThere does not seem a direct way to do this now, but in the InternalObject of the item there should be a call for it you can use as CreateTabbedFile(r”) to export the string which can be written to a file using python commands.
-Aniket
How to access Ansys help links
Guidelines for Posting on Ansys Learning Forum
-
July 28, 2023 at 4:49 am
Tomasz Walkowiak
SubscriberHello Aniket,
thank you for your response.
I was able to write a Python script that works, based on the information I've found in the following post:
/forum/forums/topic/tabular-data-extraction/My script goes through all results from the selected analysis systems
and exports defined columns (in this case #2 and #3) from the Tabular Data panel to separate .csv files.Name of each file is the name of the given result (e.g., 001_vf1_Fx_sigma_x_05t, as shown in the 2nd picture in my original post above).
import csvpath=r"D:\FEA\P22-01003\ANSYS_data_export_test" "\\"for i in range(2, len(Model.Analyses)):system=Model.Analyses[i]solution=system.Solutionfor j in range(1, len(solution.Children)):item = solution.Children[j]item.Activate()pane = ExtAPI.UserInterface.GetPane(MechanicalPanelEnum.TabularData)table = pane.ControlUnknownfrequency = []for row in range(2, table.RowsCount+1):cellText = table.cell(row, 2).Textfrequency.append(float(cellText))amplitude = []for row in range(2, table.RowsCount+1):cellText = table.cell(row, 3).Textamplitude.append(float(cellText))with open(path+item.Name+".csv", 'wb') as f:writer = csv.writer(f)writer.writerows(zip(frequency, amplitude))print('done')I just wanted to share it in case someone else has a similar problem to solve.Take care and have a good one!-
July 28, 2023 at 5:44 am
-
-
-
- The topic ‘Python script for exporting Harmonic Response analysis results to .txt files’ is closed to new replies.
-
6495
-
1906
-
1458
-
1308
-
1022
© 2026 Copyright ANSYS, Inc. All rights reserved.




