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

Nikos Kallitsis
Nikos Kallitsis Member, Employee Posts: 36
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

  • Nikos Kallitsis
    Nikos Kallitsis Member, Employee Posts: 36
    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:

    #Get current Panel boundaries
    Pane=ExtAPI.UserInterface.GetPane(MechanicalPanelEnum.Graphics)
    Width=Pane.ControlUnknown.width
    Height=Pane.ControlUnknown.height
    
    #Define the distance of the text from top left corner
    identLeft = 10
    identTop = Height-20
    
    #Remove older annotations
    g = ExtAPI.Graphics
    
    for i in g.DrawContexts:
        g.RemoveContext(i)
    g.Redraw
    
    #Create new annotations
    pt = g.CreatePixelPoint(identLeft, identTop)
    annotationUser=g.Scene.Factory2D.CreateText(pt, "Test Annotation")
    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:

    g = ExtAPI.Graphics
    
    for i in g.DrawContexts:
        g.RemoveContext(i)
    g.Redraw
    

Answers