General Mechanical

General Mechanical

Solution name in Python

    • johnstn
      Subscriber

      Hi. Is it possible to get the solution name and use it as variable on Python?

      I'd like to get this "Static Structural (A5)" and use it in a code to export the data.

      I have a lot of containers and if I keep this "DATEI_NAME", it will write the exported data in the same xls of the previous solution.

      Thank you

    • Erik Kostson
      Ansys Employee

       

       

      The way to get that name (but (A.. is not part of it is):

      ExtAPI.DataModel.Project.Model.Analyses[0].Name

       

      There is also the internalobject, which is to be used with care (might not always work):

       

      ExtAPI.DataModel.Project.Model.Analyses[0].InternalObject.DisplayName

      This gives also the (A..) part

      Erik

       

       

    • johnstn
      Subscriber

      Hi Erik

      Thank you for your answer. It works. However, I get the "(A...)" in the name.

      Is it possible to get the name of the current analysis (based on the selected results)?

      I would like to run a script for each container, not changing the [0] in the code. The script should read each result selected in "Solution" and export to an xls file.

      Thanks again

    • johnstn
      Subscriber

      I found out how to do it... 

      I added this code to find out the "i" in Analyses[i] and remove the "(A....)" from the string.

      numberAnalysis=Tree.GetPathToFirstActiveObject()
      nameAnalysis=numberAnalysis[numberAnalysis.find('[')+1:numberAnalysis.find(']')]
      nameExport=ExtAPI.DataModel.Project.Model.Analyses[int(nameAnalysis)].InternalObject.DisplayName
      nameExport=nameExport[0:nameExport.find('(')-1]

      Thanks 😀

Viewing 3 reply threads
  • You must be logged in to reply to this topic.