How to change legend values of a contour in Mechanical with scripting?
Rohith Patchigolla
Member, Moderator, Employee Posts: 193
✭✭✭✭
in Structures
I would like to change the legend values either all at once or just one value at a time in Mechanical for a result contour. How can do it via Mechanical Scripting?
Tagged:
0
Answers
-
Here are example scripts for modifying legends for a stress result. Change the units accordingly for other result types.
Change all the 10 values at once for a standard 9 Band legend. If skipping a particular value, simply replace it as None.
#Automated Script #10 Values for a standard Legend with 9 Bands #Blank can be input as None legendVals = [None,1,1.2,1.4,1.6,1.8,2,2.4,2.8,None] def changeLegend(data): legendSettings = Ansys.Mechanical.Graphics.Tools.CurrentLegendSettings() i = 1 for val in legendVals: if val != None: print i if i < len(legendVals): print "if" legendSettings.SetLowerBound(i-1, Quantity(val,"MPa")) else: print "else" legendSettings.SetUpperBound(i-2, Quantity(val,"MPa")) i += 1 changeLegend(legendVal)
Change legend values just for a particular Band of the legend (numbering from bottom - starts at 1)
#Manual Script # Select the Band Number (from bottom) BandNum = 2 #Lower_or_upper_bounds LowerLegendVal = 1.2 UpperLegendVal = None legendSettings = Ansys.Mechanical.Graphics.Tools.CurrentLegendSettings() if LowerLegendVal != None: legendSettings.SetLowerBound(BandNum-1, Quantity(LowerLegendVal,"MPa")) if UpperLegendVal != None: legendSettings.SetUpperBound(BandNum-1, Quantity(UpperLegendVal,"MPa"))
0