How to automate Annotation creation at any node?

Member, Moderator, Employee Posts: 873
100 Answers 500 Comments 250 Likes Second Anniversary
✭✭✭✭

How to automate Annotation creation at any node?

Tagged:

Welcome!

It looks like you're new here. Sign in or register to get started.

Answers

  • Member, Moderator, Employee Posts: 873
    100 Answers 500 Comments 250 Likes Second Anniversary
    ✭✭✭✭
    edited January 2024

    One can create annotations at node ID using following code:

    1. nodeID = 1984
    2. analysis=ExtAPI.DataModel.AnalysisByName('Static Structural')
    3. resultObject=ExtAPI.DataModel.GetObjectsByName('Equivalent Stress')[0]
    4. probeLabel = Graphics.LabelManager.CreateProbeLabel(resultObject)
    5. probeLabel.Scoping.Node = nodeID
    6.  
    7. with Transaction():
    8. labelsForRes = Graphics.LabelManager.GetObjectLabels(resultObject)
    9. Graphics.LabelManager.DeleteLabels(labelsForRes)
    10. probeLabel = Graphics.LabelManager.CreateProbeLabel(resultObject)
    11. probeLabel.Scoping.Node = nodeID
    12. probeLabel.Note = "NOT OK"
    13. probeLabel.Color = Ansys.ACT.Common.Graphics.Color(red=240, green=0, blue=0, alpha=50)
  • Member Posts: 32
    10 Comments First Anniversary Name Dropper
    **
    edited January 2024

    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?

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

  • Member, Moderator, Employee Posts: 873
    100 Answers 500 Comments 250 Likes Second 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:

  • Member Posts: 32
    10 Comments First Anniversary Name Dropper
    **

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

    1. probeLabel.Note
    2. probeLabel.Color
  • Member, Moderator, Employee Posts: 873
    100 Answers 500 Comments 250 Likes Second Anniversary
    ✭✭✭✭

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

  • Member Posts: 32
    10 Comments First Anniversary 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?

  • Member, Moderator, Employee Posts: 873
    100 Answers 500 Comments 250 Likes Second 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:

  • Member Posts: 32
    10 Comments First Anniversary Name Dropper
    **
    edited January 2024

    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.

  • Member, Moderator, Employee Posts: 873
    100 Answers 500 Comments 250 Likes Second 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.

  • Member Posts: 32
    10 Comments First Anniversary Name Dropper
    **

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

  • Member, Moderator, Employee Posts: 873
    100 Answers 500 Comments 250 Likes Second Anniversary
    ✭✭✭✭
    edited January 2024

    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.

  • 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!

  • Member, Moderator, Employee Posts: 873
    100 Answers 500 Comments 250 Likes Second Anniversary
    ✭✭✭✭

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

Welcome!

It looks like you're new here. Sign in or register to get started.