ViewCaptureToFile + Named Views doesn't update clipping planes

I have found a couple other threads noting a similar issue, but they aren’t using clipping planes and do not appear to have a resolution. I have a python script that uses ViewCaptureToFile for multiple Named Views. The script works just fine when the named views are just different camera locations, but if the views are clipped, they don’t update correctly before the output.

I tried adding rs.Redraw() and rs.Sleep() to increase my chances of making it work, but still does not update the clipping planes before exporting the view.

import rhinoscriptsyntax as rs
import os

all_views = rs.NamedViews() # a list of names (strings)
selected_views= rs.MultiListBox(all_views, message = "select views to save", defaults = all_views)
rs.EnableRedraw(True)

filename_base = rs.GetString("base file name","View_")
#savepath = r"/Users/User_Name/Desktop"
savepath = rs.BrowseForFolder(rs.DocumentPath(), "destination directory")
filepath = os.path.join(savepath, filename_base)

for view_name in selected_views:
    rs.RestoreNamedView(view_name)
    rs.Redraw()
    rs.Sleep(2000)
    rs.Command('-_ViewCaptureToFile '+chr(34)+filepath+view_name+'.png'+chr(34)+' _EnterEnd')

Similar topics:
ViewCaptureToFile saves the wrong mode - Scripting - McNeel Forum
Cycle through layers and namedviews using python rhinoscriptsyntax - Scripting - McNeel Forum

@jcparks I created a file with a sphere and a few named views and exported them using your scripts. What am I missing? Would you mind listing the steps to replicate the issue? and example Rhino file would also be very helpful.

This is the export I get from a named view that has a clipping plane

Ehsan, thanks for your reply.

For addition context, our working files were originally created in Rhino 7 and are still using those clipping planes not the new ones created for Rhino 8. The issue is that the view doesn’t reset for the views that follow the first. As Jake said, it doesn’t update so it seems to stay stuck on the first set of clipping planes (2 that face each other per view). Current workflow is double clicking each view, we then use a screen capture app to save to jpg. We have several files with up to 30 views in each so any help automating this would be very helpful.
Thank you!

Would it be possible to share a small Rhino file that I could use to test this?

NameView ClippingPlane.3dm (197.3 KB)
I attached a simple file to illustrate the issue. There are three Named Views, each view is associated with two clipping planes facing each other so as to only show a controlled amount of information. When I run the script, it will not update the clipping planes for each Named View. However, if I double click on each Named View then manually ViewCaptureToFile, it works. I want that capability scripted, but rs.Redraw() does not seem to update the clipping planes after rs.RestoreNamedView().

1 Like

Okay this is great!! I can replicate the problem and will report here soon.

1 Like

@jcparks I can confirm there is a difference in behaviour between the UI and rs. RestoreNamedView. I have logged the bug with information here:

RH-84218 rs. RestoreNamedView does not restore clipping planes

Thanks for reporting this!

1 Like

Would like to add a feature request related to this subject.
Named views panel thumbnails do not show an accurate preview of the view as saved with the clipping plane.
Named views

@jcparks The issue above is fixed. Let me know if you want a test build and I can sent it your way

Yes please!

@Elias_Simmonds

I added a ticket for the preview issue as well

RH-84262 NamedViews do not consider clipping planes in previews

1 Like

@eirannejad Thank you, much appreciated!

1 Like

RH-84218 is fixed in Rhino 8 Service Release 14

1 Like