I have a script that iterates through many bodies and creates images in Mechanical based on some user-input.
Because the script is designed to do this across many bodies, I thought the easiest way to improve efficiency would be to use only one result object, say a Total Deformation, scoped to all bodies, and can then just hide bodies to create views I needed.
This works well, as we only create and evaluate results once. But the issue is the legend is then based on global levels of deformation. Adjust to visible via the GUI works perfectly here, but does not seem to be exposed to be exposed directly to API via Ansys.Mechanical.Graphics.Tools.CurrentLegendSettings().
I do already have a workaround using the script below, but it is clunky to need to access the adjust to legend this way. Is there a better way to do this without needing to access undocumented functions?
import clr
clr.AddReference("Ansys.Common.Interop.261")
from Ansys.Common.Interop.WBGfxUtility import IWBGfxContainer
from System.Runtime.InteropServices import Marshal
ds_gfx = ExtAPI.Graphics.InternalObject
ptr = Marshal.GetIUnknownForObject(ds_gfx)
container = Marshal.GetTypedObjectForIUnknown(ptr, clr.GetClrType(IWBGfxContainer))
IWBGfxContainer.AdjustLegendToGraphics(container)