Can "zoom to fit" option be activated through scripting?
The following code can be used:
ExtAPI.Graphics.Camera.SetFit()
Further information on SetFit() method:
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
@cobonz , what version are you using?
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
Troubleshooting discussion can be found here:https://discuss.ansys.com/discussion/2771/graphics-camera-setfit?utm_source=community-search&utm_medium=organic-search&utm_term=ExtAPI.Graphics.Camera.SetFit()