How can I insert a custom text at the bottom left corner of the Geometry view Panel?

Member, Employee Posts: 40
10 Comments 5 Likes First Anniversary Ansys Employee
✭✭✭✭

I want to print a custom text at the bottom left corner of the Geometry view Panel. How can I do this?

Best Answer

  • Member, Employee Posts: 40
    10 Comments 5 Likes First Anniversary Ansys Employee
    ✭✭✭✭
    Answer ✓

    You can use the following Python script which creates a text annotation at the bottom left corner of all panels:

    1. #Get current Panel boundaries
    2. Pane=ExtAPI.UserInterface.GetPane(MechanicalPanelEnum.Graphics)
    3. Width=Pane.ControlUnknown.width
    4. Height=Pane.ControlUnknown.height
    5.  
    6. #Define the distance of the text from top left corner
    7. identLeft = 10
    8. identTop = Height-20
    9.  
    10. #Remove older annotations
    11. g = ExtAPI.Graphics
    12.  
    13. for i in g.DrawContexts:
    14. g.RemoveContext(i)
    15. g.Redraw
    16.  
    17. #Create new annotations
    18. pt = g.CreatePixelPoint(identLeft, identTop)
    19. annotationUser=g.Scene.Factory2D.CreateText(pt, "Test Annotation")
    20. annotationUser.Color = 0x000000

    The text's location is measured from the top left corner of the Panel. The text is displayed across all Panels, so if you need it to be removed, you can execute the following portion of the above script:

    1. g = ExtAPI.Graphics
    2.  
    3. for i in g.DrawContexts:
    4. g.RemoveContext(i)
    5. g.Redraw

Answers

Welcome!

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