How to automate Annotation creation at any node?

Pernelle Marone-Hitz
Pernelle Marone-Hitz Member, Moderator, Employee Posts: 871
100 Answers 500 Comments 250 Likes First Anniversary
✭✭✭✭

How to automate Annotation creation at any node?

Tagged:

Answers

  • Pernelle Marone-Hitz
    Pernelle Marone-Hitz Member, Moderator, Employee Posts: 871
    100 Answers 500 Comments 250 Likes First Anniversary
    ✭✭✭✭
    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: 30
    10 Comments 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: 871
    100 Answers 500 Comments 250 Likes First Anniversary
    ✭✭✭✭

    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: 30
    10 Comments 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: 871
    100 Answers 500 Comments 250 Likes First Anniversary
    ✭✭✭✭

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

  • sombodyfromtheworld
    sombodyfromtheworld Member Posts: 30
    10 Comments 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: 871
    100 Answers 500 Comments 250 Likes First Anniversary
    ✭✭✭✭

    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: 30
    10 Comments 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: 871
    100 Answers 500 Comments 250 Likes First Anniversary
    ✭✭✭✭

    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: 30
    10 Comments 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: 871
    100 Answers 500 Comments 250 Likes First Anniversary
    ✭✭✭✭
    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.

  • EnBV
    EnBV Member Posts: 2
    Name Dropper First Comment
    **

    Hi! Joining this thread with a similar question.
    I am wondering how to do something similar to @sombodyfromtheworld. I attach the code and a picture for reference.

    Code

    active_plots = []
    active_NSs = []

    for ActObj in ExtAPI.DataModel.Tree.ActiveObjects:
    if ActObj.GetType() == Ansys.ACT.Automation.Mechanical.NamedSelection:
    active_NSs.append(ActObj)
    else:
    active_plots.append(ActObj)

    for plot in active_plots:
    Graphics.LabelManager.DeleteLabels(Graphics.LabelManager.GetObjectLabels(plot))
    for NS in active_NSs:
    probeLabel = Graphics.LabelManager.CreateProbeLabel(plot)
    probeLabel.Scoping.Node = NS.Location.Ids[0]

    Basically what I do is selecting two or more NSs containing a node reference and use this info to create labels in plots (this case is a max principal stress plot).
    The tool works fine for 3D bodies. However, when having top and bottom plots showing 2D shell bodies, it always takes as reference the bottom plot position when providing a node number as scoping. In my case, this is not desirable, because stresses are way higher in the top plot position (see attached pic). I have not seen any attribute to change the plot position for label extraction from bottom to top.
    I have thought of a workaround consisting of only reading both top and bottom stress values and comparing them using code before creating the label, but I don't know if that may be possible.
    I would appreciate any help!
    Thanks!

  • Pernelle Marone-Hitz
    Pernelle Marone-Hitz Member, Moderator, Employee Posts: 871
    100 Answers 500 Comments 250 Likes First Anniversary
    ✭✭✭✭

    @AKD-Scripting-Team Could someone have a look at this one please? Thanks