Copy Paste to all Layouts with Python

Hi all,

Is there a way to copy pasted an object (or a selection of objects) to all layouts? If I copy/paste a block to all layouts then I only need to edit the block once then all instances of the block on all layouts will be updated.

I got as far as this with Python, I’d like to know how to activate each layout iteratively, I don’t think my code for activate layout is working:

import rhinoscriptsyntax as rs
import Rhino
import scriptcontext as sc

pageViews = sc.doc.Views.GetPageViews()

for pageView in pageViews:
    Rhino.Display.RhinoPageView.SetPageAsActive(pageView)
    
    rs.Command('_Paste')

Any pointer would be greatly appreciated
Thank you in advance

Hi David,

To activcate all layouts you can do this:

for view_name in rs.ViewNames(return_names = True, view_type=1):
    rs.CurrentView(view_name)

Does that help?

let us know if you have more questions
-Willem

2 Likes

thank you @Willem, it totally worked!

for anyone who needs it, the script lets you select an annotation object on one layout and copy/paste it to all layouts in the Rhino doc. :slight_smile:

import rhinoscriptsyntax as rs


obj = rs.GetObject("Select annotation on layout to copy to all", rs.filter.annotation)

rs.SelectObject(obj)
rs.Command('_CopyToClipboard')

rs.EnableRedraw(False)

for view_name in rs.ViewNames(return_names = True, view_type=1):
    rs.CurrentView(view_name)
    rs.Command('_Paste')
    
rs.EnableRedraw(True)
1 Like