"Zoom to fit" option in Mechanical?

Member, Moderator, Employee Posts: 873
100 Answers 500 Comments 250 Likes Second Anniversary
✭✭✭✭
edited June 2023 in Structures

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

Tagged:

Welcome!

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

Best Answer

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

    The following code can be used:

    ExtAPI.Graphics.Camera.SetFit()

    Further information on SetFit() method:

Answers

  • Member Posts: 13
    10 Comments First Anniversary
    **

    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

  • Member, Employee Posts: 385
    25 Answers 100 Comments Second Anniversary 25 Likes
    ✭✭✭✭

    @cobonz , what version are you using?

  • Member Posts: 13
    10 Comments First Anniversary
    **
    edited December 2023

    Hi Mike,

    i am using 23R2

    Thats part of the code

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

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

Welcome!

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