"Zoom to fit" option in Mechanical?

Pernelle Marone-Hitz
Pernelle Marone-Hitz Member, Moderator, Employee Posts: 741
First Comment First Anniversary Ansys Employee Solution Developer Community of Practice Member
edited June 2023 in Structures

Can "zoom to fit" option be activated through scripting?

Tagged:

Best Answer

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

    The following code can be used:

    ExtAPI.Graphics.Camera.SetFit()

    Further information on SetFit() method:

Answers

  • cobonz
    cobonz Member Posts: 6
    First Comment

    Hey, I try to use the command when updating the project from Workbench. I export images from Van Mies Stresses and want them to set Camera.SetFit(). If i do my code from within Mechanical it works fine, but it does not work when updating from outside. Is there an workaround

  • Mike.Thompson
    Mike.Thompson Member, Employee Posts: 241
    First Anniversary First Comment 5 Likes Ansys Employee

    @cobonz , what version are you using?

  • cobonz
    cobonz Member Posts: 6
    First Comment
    edited December 2023

    Hi Mike,

    i am using 23R2

    Thats part of the code

    for view in views:
                    if m % 3 == 0:
                            html_content += '  <tr>\n'
                    m = m+1
                    Graphics.Camera.SetSpecificViewOrientation(view)
                    ExtAPI.Graphics.Camera.SetFit()
                    a= StressResult.AddFigure()
                    a.Name = a.Parent.Parent.Name+' '+name+' '+str(view)
                    output_image_path = r"R:\delete_tmp\{0} {1} {2}.png".format(a.Parent.Parent.Name,name,str(view))
                    Graphics.ExportImage(output_image_path, GraphicsImageExportFormat.PNG, image_settings)
                    html_content += '<td><img src="{}" alt="Image"></td>\n'.format(output_image_path)
                    FigureList.append(a)
    

    If you want to rebuilt this: It happens when one model dimension is far larger then the others