How to set common max and min values for contour plots across different result objects?
Tasos
Member, Employee Posts: 8
✭✭✭
In the context of transient analysis, when requesting a result at all sets, each result has its own upper and lower bounds for the contour plot. I want to have a common contour plot scale across my set of results on different time steps so I can make effective comparisons.
Tagged:
1
Best Answer

To automate this workflow, you can place the result set under a common group in the model tree. Then, with the Group object selected (active) in the tree, use the following script.
The script iterates over all the results in the group, reads each upper and lower bound, then finds the total maximum and minimum of the set, and applies these as common bounds for all the contour plots.
(Script tested in 2023R1 and 2024R2)# With the group of results selected: rgroup = ExtAPI.DataModel.Tree.ActiveObjects[0] # Initialising lists of all maxima and minima minlist = [] maxlist = [] # Iterating over the result objects in the group to get all maxima and minima for ri in rgroup.Children: # Getting current result legend data ExtAPI.DataModel.Tree.Activate(ri) clset = Ansys.Mechanical.Graphics.Tools.CurrentLegendSettings() # Get current minimum: cmin = clset.GetLowerBound(0) # Lower bound of lower band. # GetLowerBound outputs Quantity type, so we'll postproecess it to get a float cmin = str(cmin) # Convert to String type cmin = cmin.Split(' ')[0] # Splitting and keeping the first, numerical part cmin = float(cmin) # Converting to float type minlist.append(cmin) # Get current maximum: nob = clset.NumberOfBands cmax = clset.GetUpperBound(nob1) # Upper bound of upper band # GetUpperBound outputs Quantity type, so we'll postproecess it to get a float cmax = str(cmax) # Convert to String type cmax = cmax.Split(' ')[0] # Splitting and keeping the first, numerical part cmax = float(cmax) # Converting to float type maxlist.append(cmax) # Iterating over all results and setting the global minimum and maximum as top and bottom contour limits tmin = min(minlist) tmax = max(maxlist) for ri in rgroup.Children: ExtAPI.DataModel.Tree.Activate(ri) clset = Ansys.Mechanical.Graphics.Tools.CurrentLegendSettings() clset.SetLowerBound(0,Quantity(tmin,'W m^1 m^1')) clset.SetUpperBound(nob1,Quantity(tmax,'W m^1 m^1'))
3