Unable to export force-reaction tabular data during parametric study

Hello everyone,

I recently read a blog by Rohith about exporting images after each design point run and one more about exporting a Frequency curve from a Harmonic Response analysis, all sing Python object After Post.

I am running into a problem when I try to do the same for a Force reaction result that I have in my static analysis:

Apparently the force reaction object does not have a tabular data function.

I tried to access the object using the following snippet:

# get the chart object
        chart = DataModel.GetObjectsByName("Force Reaction")[0]
        chart.Activate()

        #time.sleep(2

        # open the file for writing
        with open(outputFile, 'w') as f:
            # write column headers
            #f.write("Time [s]\tContactForce [N]\n")

            # get tabular data
            tabularData = ExtAPI.UserInterface.GetPane(MechanicalPanelEnum.TabularData)
            con = tabularData.ControlUnknown

            # loop through rows and write column entries to file
            for row in range(1,con.RowsCount+1):
                f.write("{}\t{}\n".format(
                    con.cell(row,2).Text,
                    con.cell(row,6).Text))

This works, but only if Mechanical UI is open. It does not work for design points that run in the background.

Do you happen to know a workaround for this problem? Would appreciate a response on this!

Thank you.

Regards,
Paritosh

Tagged:

Answers

  • Mike.Thompson
    Mike.Thompson Member, Employee Posts: 357
    25 Answers 100 Comments Second Anniversary 25 Likes
    ✭✭✭✭

    You are correct that your methodology will not work without the UI as the UI controls are not being updated and that is where you are getting your data for export. It is generally not a recommended practice to do that for this limitation; however, it is something that can be used with proper understanding.

    I would propose that this method is actually "the work around" and the robust or "real" solution for this is to calculate the reaction forces with DPF and export the data from that.

    See a post here for such an example. It may not be exactly what you are looking for, but should be similar and able to be adopted.

    https://discuss.ansys.com/discussion/3387/how-do-i-calculate-force-reactions-total-xyz-force-for-lots-of-contacts-for-all-time-points