TAGGED: python-scripting
-
-
September 12, 2025 at 2:43 pm
FS
SubscriberI have a transient thermal model which solves at a number of times steps, the number may vary from simulation conditions. The results at each time step are stored in a solution folder.

For postprocessing I want to export the (in this case) temperature at each time step. I have created the following script. However it requires to enter the number of children manually. How can I determine the number of children, such as to remain the script untouched independent of the solution. BTW:r1.Children
does not work.
Script:
'''
Export all children in solution folder 'Temperature'
'''
import os
analysis=ExtAPI.DataModel.Project.Model.Analyses[0]
locationToExport = analysis.WorkingDir
# Enter number time steps
nsteps = 20
steps = list(range(2,nsteps+2))
for i in steps:
  resultsName = 'Temperature '+ str(i)
  fileName = resultsName + '.txt'
  fileToExport = os.path.join(locationToExport,fileName)
  r1=ExtAPI.DataModel.GetObjectsByName(resultsName)[0]
  r1.ExportToTextFile(fileToExport) -
September 15, 2025 at 7:11 am
ErKo
Ansys EmployeeÂ
Â
Â
Â
Â
Hi
It is because you are selecting on names (Getobjectbyname) and the Temperature 1 or 2 names are likely used by a temperature bc also.
To resolve this, change the names (temp. bc) to say Mytemp1,…, instead and it all works.
Or select all temperature results and loop through them and export:made this example: https://discuss.ansys.com/discussion/9888/how-to-export-temperature-results-to-text-files-using-mechanical-scripting
All the best
Erik
Â
Â
Â
Â
Â
-
September 27, 2025 at 1:00 pm
Rohith Patchigolla
Ansys EmployeeHi,Â
If you want to be sure that you are searching by name only items of the type Grouping Folder and only those under Solution of a particular analysis, please try the below script.Â
#Assuming its the first analysis in the tree
Analysis = DataModel.AnalysisList[0]
solution = Analysis.Solution
GroupName = "Temperature"
myGroup = [child for child in solution.Children if child.Name ==GroupName and child.DataModelObjectCategory == DataModelObjectCategory.TreeGroupingFolder][0]
allChildren = myGroup.Children
print(len(allChildren))Â
-
- You must be logged in to reply to this topic.
- LPBF Simulation of dissimilar materials in ANSYS mechanical (Thermal Transient)
- Simulate a fan on the end of shaft
- Nonlinear load cases combinations
- Real Life Example of a non-symmetric eigenvalue problem
- How can the results of Pressures and Motions for all elements be obtained?
- Contact stiffness too big
- Test post on Forum – LLM response – SC
- 13-Node Pyramid Element Shape Function
- Element Birth and Death
- Python-Script to Export all Children of a Solution Tree
-
4492
-
1494
-
1376
-
1209
-
1021
© 2025 Copyright ANSYS, Inc. All rights reserved.