Get view by name (str)

I know I can get layout names by sc.doc.Views.GetPageViews() then get the PageName property. Is there a way to do it in the opposite way? Get the PageView object by its name.

Thanks!

Hi Hali,

Does the example below makes sense, if not let me know.

import scriptcontext as sc

plist = sc.doc.Views.GetPageViews()

name_to_get = 'Page 1'

found_pages = []
for page in plist:
    if page.PageName == name_to_get:
        found_pages.append(page)

print found_pages

-Willem

Hey Willem,

Yes, the script totally make sense. However, it still relies one getting all the PageView objects first. If I have 200-300 views in the model. It may not be very efficient. But thank you for the help! What I really mean in the question is how can I call an specific PageView object, by a specific name (str).

The approach suggested by @Willem is correct.

– Dale

1 Like

I don’t know how fast you need your script to be but even going through 300 pages I expect to be quick,
Note that there can be multiple pages with the same name hence my adding found pages to a list.

1 Like

Got it! May need some further tests for the speed. The goal is to produce high quality architectural sheets (36"x48", 300dpi, whole pacage will have 100-300 sheets). Thanks a lot for the solution!