# Update many pages with ruby

**URL:** <https://forums.sketchup.com/t/update-many-pages-with-ruby/49134>\
**Category:** Ruby API\
**Tags:** update, layers, page, transition, properties\
**Created:** [July 28, 2017, 10:44am UTC](https://forums.sketchup.com/t/update-many-pages-with-ruby/49134 "2017-07-28T10:44:00Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![paolodanielli](https://avatars.discourse-cdn.com/v4/letter/p/53a042/32.png) [@paolodanielli](https://forums.sketchup.com/u/paolodanielli)\
**Post date:** [July 28, 2017, 10:44am UTC](https://forums.sketchup.com/t/update-many-pages-with-ruby/49134/1 "2017-07-28T10:44:00Z")

</div>

How is the best way to update pages?  
I’m developing a function that turn off one or more layers in all the scenes.  
Im’ finding problems to update the scenes.

Here is the idea (later i’ll post the code, I’m out of the office).

- Activate the page
- Turn the layer off
- Update the scene  
The problem is: Update of the scene happens before view is oriented, so the camera of the scene changes.

---

<div class="post-metadata">

**Author:** ![DaveR](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/daver/32/7601_2.png) [@DaveR](https://forums.sketchup.com/u/DaveR)\
**Post date:** [July 28, 2017, 11:02am UTC](https://forums.sketchup.com/t/update-many-pages-with-ruby/49134/2 "2017-07-28T11:02:20Z")

</div>

So between selecting the scene and updating, you’re moving the camera?

If you were doing this using the native tools and all you want to do is update the layer state, you would set Camera and other scene attributes to be left alone by unticking the boxes in Properties to save. Can you do that in your code?

---

<div class="post-metadata">

**Author:** ![tt\_su](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/tt_su/32/17_2.png) [@tt\_su](https://forums.sketchup.com/u/tt_su)\
**Post date:** [July 28, 2017, 11:07am UTC](https://forums.sketchup.com/t/update-many-pages-with-ruby/49134/3 "2017-07-28T11:07:55Z")

</div>

> [@paolodanielli](#):
>
> The problem is: Update of the scene happens before view is oriented, so the camera of the scene changes.

Can you snow a snippet that reproduce the issue you’re running into?

---

<div class="post-metadata">

**Author:** ![Aerilius](https://avatars.discourse-cdn.com/v4/letter/a/e19b73/32.png) [@Aerilius](https://forums.sketchup.com/u/Aerilius)\
**Post date:** [July 28, 2017, 11:08am UTC](https://forums.sketchup.com/t/update-many-pages-with-ruby/49134/4 "2017-07-28T11:08:30Z")

</div>

As I understand, activating a scene (page) changes the camera to the one saved in the scene, but you want to update different scenes without having a visible effect to the user.

The question is why you activate the scene at all. The Ruby API allows to get a reference to any scene – not necessarily the active one. You can change a [scene’s layer visibility setting](http://ruby.sketchup.com/Sketchup/Page.html#set_visibility-instance_method) without turning the actual on layer on/off. Or is there a limitation of what the API makes possible?

---

<div class="post-metadata">

**Author:** ![paolodanielli](https://avatars.discourse-cdn.com/v4/letter/p/53a042/32.png) [@paolodanielli](https://forums.sketchup.com/u/paolodanielli)\
**Post date:** [July 28, 2017, 12:49pm UTC](https://forums.sketchup.com/t/update-many-pages-with-ruby/49134/5 "2017-07-28T12:49:09Z")

</div>

This is the better way at the end; quick and easy.  
I was looking for something general (to change other properties in the future)  
But I will deal with the problem when it will be

---

<div class="post-metadata">

**Author:** ![sdmitch](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/sdmitch/32/31265_2.png) [@sdmitch](https://forums.sketchup.com/u/sdmitch)\
**Post date:** [July 28, 2017, 1:50pm UTC](https://forums.sketchup.com/t/update-many-pages-with-ruby/49134/6 "2017-07-28T13:50:28Z")

</div>

> [@paolodanielli](#):
>
> The problem is: Update of the scene happens before view is oriented, so the camera of the scene changes.

To eliminate this problem turn off the transition option

Sketchup.active\_model…options[“PageOptions”][“ShowTransition”]=false

---

<div class="post-metadata">

**Author:** ![Aerilius](https://avatars.discourse-cdn.com/v4/letter/a/e19b73/32.png) [@Aerilius](https://forums.sketchup.com/u/Aerilius)\
**Post date:** [July 28, 2017, 2:01pm UTC](https://forums.sketchup.com/t/update-many-pages-with-ruby/49134/7 "2017-07-28T14:01:48Z")

</div>

By using a reference to the page you want to modify (instead of making it active), you can call the `update(flags)` method to update specific properties.

It seems the API lacks a way to specify the values of these properties, but it can only take them from the current view, which requires changing the camera of the active view. The better solution would be if the page had a `camera=` method.

> [@sdmitch](#):
>
> Sketchup.active\_model.options[“PageOptions”][“ShowTransition”]=false

Mutating a global model option (to achieve a local effect through this script) may not be in the interest of the user. You can do this as a workaround and remember to set the PageOptions back to their previous value afterwards.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/sketchup/original/3X/f/2/f2a121500b085ed60806607a82720b092d800bb3.png) [@system](https://forums.sketchup.com/u/system)\
**Post date:** [October 28, 2017, 6:02am UTC](https://forums.sketchup.com/t/update-many-pages-with-ruby/49134/8 "2017-10-28T06:02:03Z")

</div>

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.
