Elena Maier
Subscriber

 

 

 

Thank you again, I got access to v2022R1 and I can insert a Python Code now.

I insertet this code:

def after_post(this, solution):
    import os
    import wbjn

    # Get Design Point Number as Text (to append it to the file name)
    dpn = wbjn.ExecuteCommand(ExtAPI, “returnValue(a+Parameters.GetActiveDesignPoint().Name)”, a=”DP”)

    # Get the User Files Directory of the Project to save files.
    UserFilesDir = wbjn.ExecuteCommand(ExtAPI, “returnValue(GetUserFilesDirectory())”)

    for analysis in ExtAPI.DataModel.AnalysisList:
        # Get all the results objects in the analysis tree
        results = [child for child in analysis.Solution.Children]

        for result in results:
            if result.DataModelObjectCategory == DataModelObjectCategory.SIFResult:  # Check if it’s a stress intensity factor result
                result.Activate()
                
                # Get the table for stress intensity factor (K1)
                sif_table = result.Tables.FindObject(“Stress Intensity Factor K1”)
                
                if sif_table is not None:
                    # Export the table data to a CSV file
                    fName = dpn + “_” + result.Name + “_” + analysis.Name + “_SIF.csv”
                    fPath = os.path.join(UserFilesDir, fName)
                    sif_table.ExportToCSV(fPath)




1. question: But there is no Excel in the user_file, so I don´t get the results. I don´t know how to get acces to the table with the solution for all the different contours. How can I get to the fracture tool and the SIFS(K1) with Python. 

2. Before that, I tried what is explained here: https://developer.ansys.com/blog/script-tip-friday-python-code-object-mechanical, but ANSYS only export the picture of the current design point. So I need the Table Data for all the design points, not only the current one. Could you help me with that problem too?

Thank you so much for your help. Solving this problem would save me so much time.

Best regards and thank you for your time again,

Elena