How to automate Annotation creation at any node?

Pernelle Marone-Hitz
Pernelle Marone-Hitz Member, Moderator, Employee Posts: 712
First Anniversary Ansys Employee Solution Developer Community of Practice Member First Answer

How to automate Annotation creation at any node?

Tagged:

Answers

  • Pernelle Marone-Hitz
    Pernelle Marone-Hitz Member, Moderator, Employee Posts: 712
    First Anniversary Ansys Employee Solution Developer Community of Practice Member First Answer
    edited January 12

    One can create annotations at node ID using following code:

    nodeID = 1984
    analysis=ExtAPI.DataModel.AnalysisByName('Static Structural')
    resultObject=ExtAPI.DataModel.GetObjectsByName('Equivalent Stress')[0]
    probeLabel = Graphics.LabelManager.CreateProbeLabel(resultObject)
    probeLabel.Scoping.Node = nodeID
    
    with Transaction():
        labelsForRes = Graphics.LabelManager.GetObjectLabels(resultObject)
        Graphics.LabelManager.DeleteLabels(labelsForRes)
        probeLabel = Graphics.LabelManager.CreateProbeLabel(resultObject)
        probeLabel.Scoping.Node = nodeID 
        probeLabel.Note = "NOT OK"
        probeLabel.Color = Ansys.ACT.Common.Graphics.Color(red=240, green=0, blue=0, alpha=50)
    
  • sombodyfromtheworld
    sombodyfromtheworld Member Posts: 26
    First Comment Name Dropper
    edited January 12

    Hi @Pernelle Marone-Hitz
    It appears that the labels are not adjusting according to the deformation scale in this view. How can I ensure they are displayed correctly, taking into account True Scale Deformation?

    s = DataModel.GetObjectById(73)
    p = GRAPHICS.LabelManager.CreateProbeLabel(s)
    p.Scoping.Node = 136
    

  • Pernelle Marone-Hitz
    Pernelle Marone-Hitz Member, Moderator, Employee Posts: 712
    First Anniversary Ansys Employee Solution Developer Community of Practice Member First Answer

    Hi @sombodyfromtheworld , I think this might be related to a Mechanical limitation in older versions. In 2023R2, the label does follow the deformation scale:

  • sombodyfromtheworld
    sombodyfromtheworld Member Posts: 26
    First Comment Name Dropper

    Thank you. Strange, I have the latest revision. Also none of this options are visible:

    probeLabel.Note
    probeLabel.Color 
    
  • Pernelle Marone-Hitz
    Pernelle Marone-Hitz Member, Moderator, Employee Posts: 712
    First Anniversary Ansys Employee Solution Developer Community of Practice Member First Answer

    Hum, this is weird. Could you try turning on beta options?

  • sombodyfromtheworld
    sombodyfromtheworld Member Posts: 26
    First Comment Name Dropper

    @Pernelle Marone-Hitz said:
    Hum, this is weird. Could you try turning on beta options?

    Could you please point where I do change to beta?

  • Pernelle Marone-Hitz
    Pernelle Marone-Hitz Member, Moderator, Employee Posts: 712
    First Anniversary Ansys Employee Solution Developer Community of Practice Member First Answer

    Sure. From the WB project schematic, go to tools /option:

    Then go to "appearance":

    and scroll to find "beta options" and tick the box next to it:

  • sombodyfromtheworld
    sombodyfromtheworld Member Posts: 26
    First Comment Name Dropper
    edited January 15

    Hi @Pernelle Marone-Hitz, thanks for tips.
    Yes, I can confirm that it was an issue with the older release (I had actually 2023R1). Now I have installed a newer 2024R1 and it worked.

    Can I also get your attention, how to only display a dot without any Label info.

  • Pernelle Marone-Hitz
    Pernelle Marone-Hitz Member, Moderator, Employee Posts: 712
    First Anniversary Ansys Employee Solution Developer Community of Practice Member First Answer

    Hi @sombodyfromtheworld , this example is to create labels. These can be scoped to nodes. What you seem to want to do is create some sort of drawing (ie, a circle). What you would need is to explore the Graphics API. There are some examples available:
    https://discuss.ansys.com/discussion/2264/draw-an-arc-and-a-circle
    https://discuss.ansys.com/discussion/395/how-to-use-the-graphics-api-to-draw-objects-for-example-a-line
    However I don't think these graphics objects will follow the deformation scale factor.

  • sombodyfromtheworld
    sombodyfromtheworld Member Posts: 26
    First Comment Name Dropper

    There is no way to make a label text and lable line and fill to be transparent?

  • Pernelle Marone-Hitz
    Pernelle Marone-Hitz Member, Moderator, Employee Posts: 712
    First Anniversary Ansys Employee Solution Developer Community of Practice Member First Answer
    edited January 15

    You could try to play with probeLabel.Color = Ansys.ACT.Common.Graphics.Color(red=240, green=0, blue=0, alpha=50) where alpha will be transparency.