General Mechanical

General Mechanical

Topics related to Mechanical Enterprise, Motion, Additive Print and more.

Design point reslut export

    • Elena Maier
      Subscriber

      Hello,

      I perform a parameter study in which I am interested in the results from the fracture tool and in specific in the SIFS.

      I have a lot of different design points.
      Is there a way to calculate all the design points using "update all design points" and at the same time export all the data for the different SIFSs (in a external file).

       

      Because I need the complete plot, all SIFS for my parameter study and it is really inefficient to "set as current" and then "open modell" with every design point. And over the normal function I can only see Kmin and Kmax.

      Thank you so much in advance.

      Elena 

    • Elena Maier
      Subscriber

      I already tried to use the ACT-extension for MultiObjectExport. But I dont know what to put in "Object Base Name", because if i put in "SIFS (K1") or "Fracture Tool" it says that doesn´t exist and can´t be exported. Also if I run all design points it does not export the data automatically. Is there any solution to fix this?

    • Rohith Patchigolla
      Ansys Employee

      Hello, 
      We can export the results using Mechanical scripting. To automate this process, we can include the mechanical script inside "Python Code" object under Solution. However, this is valid from v2021R2. 

      Is it possible for you to upgrade?

      Best regards,
      Rohith

    • Elena Maier
      Subscriber

      That sounds good, I am working with v2021R1, would that version work too or just from R2 on?
      (Otherwise I can try to get access for v2022R1.)

      Where exactly would I put the Python Code?

      Best regards and thank you so much

      Elena




    • Rohith Patchigolla
      Ansys Employee

      The "Python Code" object has been introduced in Mechanical since 2021R2. So, using 2021R2 or newer should work. 

      You can RMB on Solution --> Insert --> Python Code (with Target Callback --> After Post)

      Please create first a Mechanical script to automate the export of results. You can use Scripting Console in Mechanical develop this script. Then you can plug this into Python Code object to do the export automatically after solving the model. 

       

      • Elena Maier
        Subscriber

        It would be great, if you could help me with the code, because I can´t find information, how to access the Stress intensity factor SIFS and also how to export the data as a table. And how to export more than the current design point information.

        To solve this could really help me and save so much time.

        Looking forward to an answer.

    • 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

       

       

       

    • Rohith Patchigolla
      Ansys Employee

      Hello Elena, 

      Please test your script first in the mechanical scripting console to make sure sif_table is correctly extracted before writing it out to the csv file. 

      From my understanding, these two lines are incorrect. Please check. For example, SIFResult Data Model Object Category doesn't exist. 

      if result.DataModelObjectCategory == DataModelObjectCategory.SIFResult:  # Check if it’s a stress intensity factor result

      sif_table = result.Tables.FindObject(“Stress Intensity Factor K1”)

      Please let me know what was the source of the above lines to check if I am missing something. 

      Best regards,

      Rohith

       

    • Elena Maier
      Subscriber

      Hey Rohith,

      thank you so much for your answer and sorry that I didn´t try to script in the mechanical scripting before try it in the python extension.

      Now I tried to run it in the mechanical scripting before. I have different problems:

      1. I don´t know how to export a table instead of the pictures in ANSYS (because I want to export all the results of the stress intesity factor).

      2. Which ObjectCategory is used for the StressIntensityFactors? (I can´t find it and also the things that mechanical scripting suggest are not the result I am searching for, thats what I tried to do with this lines:

      if result.DataModelObjectCategory == DataModelObjectCategory.SIFResult:  # Check if it’s a stress intensity factor result

      sif_table = result.Tables.FindObject(“Stress Intensity Factor K1”), I tried to get access to the fracture tool)

      3. Only the data for the current DesignPoint is exported and the others aren´t.

      4. If I run the mechanical script with the original code from the website, nothing happens.

      I know this is a big question, and probably the forum is not the right place for it, but I don´t know where else to ask, since I can´t find any information about it. Normally I am not using the mechanical scripting function and use the graphical user interface, that´s why I have so many questions. Sorry for that.

      It would be great, if you could help me, because it seems that there is no other way to export data automatically from different design points in any other way.

      Best regards,

      Elena

    • Rohith Patchigolla
      Ansys Employee

      Hi Elena, 

      I understand. I would suggest opening a new post in ANSYS Developer forum as this is the place for scripting related questions. 

      https://discuss.ansys.com/

      Also, please check the existing discussions, perhaps, a similar query might already have been answered. 

      For checking DataModelObjectCategory, you can activate a particular object in the Mechanical Tree and type the below commands. 

      activeObj = Tree.FirstActiveObject

      activeObj.DataModelObjectCategory

      Best regards,

      Rohith

Viewing 8 reply threads
  • The topic ‘Design point reslut export’ is closed to new replies.