Scene with ruby


#1

Hello,
I have a Sketchup model with several scenes,
I am writing a ruby script and I want it runs in all the scenes (a scene after the other) for the moment I only runs in the “active scene” (selected_page) do you have an idea ?

Thank’s for your help


#2

In the Ruby API, scenes are called “Pages”. You access them via Sketchup.active_model.pages. Use Pages#each to iterate through the pages or Pages#selected_page= to activate one.


#3

Thank you for your reply,
But I still do not get to do what I want.
My script runs as many times as I have pages, but he recovered every time properties (name in my case) of selected pages which is selected no other :

My script is :
"…
model = Sketchup.active_model
pages = model.pages
pages.each{|pages|
si=model.pages.selected_page.name"

I do my operations then I finish by }

I tried to replace the “selected_page” by “current_page”, “active_page” and many other things but it doesn’t work

Do you have an idea ?

Thank’s for your help


#4

Do not re-use the variable |pages| inside the loop, use |page|


#5

logical !!
thank you very much jim


#6

To clarify further…

pages.each{|page|
  si=page.name
  ...
}

the above ‘page’ is a reference to the page in the array of pages
whereas ‘selected_page’ is the current active-scene-tab…
???