How to export Frequency Response Amplitude and Phase from Mechanical?
Rohith Patchigolla
Member, Moderator, Employee Posts: 206
✭✭✭✭
in Structures
I have the Frequency response result from Harmonic Analysis and I want to export the Frequency, Amplitude and Phase information from Mechanical.
Tagged:
0
Answers
-
We can do it using the below script via Python Code with "After Post" callback. This would work both in GUI mode (mechanical open) and also in Batch mode (Mechanical closed). This would work in Windows as well as Linux. Tested in 23R1 - 24R1.
Please feel free to modify the code as needed.
def after_post(this, solution):# Do not edit this line """ Called after post processing. Keyword Arguments : this -- the datamodel object instance of the python code object you are currently editing in the tree solution -- Solution """ # To access properties created using the Property Provider, please use the following command. # this.GetCustomPropertyByPath("your_property_group_name/your_property_name") # To access scoping properties use the following to access geometry scoping and named selection respectively: # this.GetCustomPropertyByPath("your_property_group_name/your_property_name/Geometry Selection") # this.GetCustomPropertyByPath("your_property_group_name/your_property_name/Named Selection") import csv freqRespObj = DataModel.GetObjectsByType(DataModelObjectCategory.DeformationFrequencyResponse)[0] tabData = freqRespObj.TabularData freqData = list(tabData['Frequency']) AmpData = list(tabData['Amplitude']) phaseData = list(tabData['Phase Angle']) csv_file = r"D:\output.csv" data = zip(freqData, AmpData, phaseData) with open(csv_file, 'wb') as file: writer = csv.writer(file) writer.writerow(['Frequency', 'Amplitude', 'Phase Angle']) writer.writerows(data)
1