Let's assume you are trying to add a probe to a figure for one of your result objects:
The Graphics.LabelManager.CreateProbeLabel( ) does not support figure objects as input:
A workaround to this limitation has been developed by our colleague, Logan.
The user has to generate the figure object of interest under the base result object (res).
res
figure = res.AddFigure()
Then, they need to create the probe labels for the result object. Let's assume that the generated probe objects are gathered in a probes list.
probes
The following snippet goes over the probes and uses the Graphics.LabelManager.CreateLabel() method to generate general annotations, instead. Then, the data form the actual probe are copied and added to the annotation for display.
Graphics.LabelManager.CreateLabel()
for label in probes: if label.GetType() != Ansys.Mechanical.Graphics.Labels.ProbeLabel: continue # avoids general user annotations (LabelManager.CreateLabel(...) or Home > Insert > Annotation) mock_figure_label = Graphics.LabelManager.CreateLabel(figure) mock_figure_label.Scoping = label.Scoping mock_figure_label.Note = "None" if label.Value is None else str(label.Value)
Note that these general annotations will not update dynamically if the result changes.
Users may be able to take advantage of a Python code object with an appropriate callback setting to implement a clear-and-regenerate logic.