My favorites | English | Sign in

Faster apps faster - GWT 2.0 with Speed Tracer New!

Google SketchUp Ruby API

Pages

class

Parent: Entity

Introduction

SketchUp 6.0+

The Pages class contains methods for manipulating a collection of Pages (scenes) in a model.

You get a handle to this collection by calling Model.pages.

     model = Sketchup.active_model
     pages = model.pages

Methods

Pages.[]SketchUp 6.0+

The [] method retrieves a page by either name or index.

Arguments:

index_or_name
The index or the string name of the specific page.

Returns:

page
a Page object if successful
 model = Sketchup.active_model
 pages = model.pages
 status = pages.add "Page 1"
 status = pages.add "Page 2"
 page = pages["Page 2"]
 if (page)
   UI.messagebox page
 else
   UI.messagebox "Failure"
 end

Pages.addSketchUp 6.0+

The add method is used to add an empty Page object to the collection.

If no name is given, then a new name is generated using the default name for new Pages. If a name is given, then a new Page with that name is added.

If the flags parameter is given, it controls which properties are saved with the Page. See the Page.update method for a description of the flags that can be set.

If index is given, it specifies the position in the page list that the new page is added. Otherwise the new page is added to the end.

Arguments:

name
The name of the specific page.
flags
(optional) Bit flags in integer form.
index
(optional) Index of where to inset.

Returns:

nil
 model = Sketchup.active_model
 pages = model.pages
 status = pages.add "Page 1"
 status = pages.add "Page 2"
 if (status)
   UI.messagebox status
 else
   UI.messagebox "Failure"
 end

Pages.add_frame_change_observerSketchUp 6.0+

The add_frame_change_observer method is used to add a new frame change observer that is called with each frame of an animation, meaning the end user has clicked on a Scene tab (aka Page) inside SketchUp and the camera is animating to that scene.

The argument is an object that implements a method frameChange with the following form:

This method is called during a slide show or creation of an animation after the camera has been set up, but before the frame is displayed. It give you a chance to perform your own actions during the animation. The arguments for frameChange method are the Page that you transition from (fromPage), the Page that you transition to (toPage), and a percent_done between 0.0 and 1.0 that tell you the percentage of the way between the two pages.

By watching the percent_done for 1.0, you can activate Ruby code that executes as soon as the user's camera has finished animating.

The method returns an integer id that can be stored and later used to remove the observer with the Pages.remove_frame_change_observer method.

Note: In SketchUp 6 and 7, the fromPage argument into the callback does not appear to be populated on the PC. You can store a variable that keeps track of the toPage and then use that on a subsequent Scene selection to determine the last Page that the user was on.

Arguments:

object
An object that implements the frameChange method.

Returns:

id
A unique id of the observer
 id = Sketchup::Pages.add_frame_change_observer(FrameChangeObserver.new)

Pages.add_matchphoto_pageSketchUp 7.0+

The add_matchphoto_page method is used to add a photomatch page to the model. This is an advanced feature that was added to support internal SketchUp work, so it is unlikely to be useful to you.

Arguments:

image_name
String image name.
camera
(optional) Camera object.
page_name
(optional) String page name.

Returns:

page
the new photomatch page.
 pages = Sketchup.active_model.pages
 page = pages.add_matchphoto_page "Test"

Pages.add_observerSketchUp 6.0+

The add_observer method is used to add an observer to the Pages object. See the PagesObserver interface for more details.

Arguments:

observer
An observer.

Returns:

true if successful, false if unsuccessful.
 pages = Sketchup.active_model.pages
 status = pages.add_observer observer

Pages.countSketchUp 6.0+

The count method is an alias for size. See also Page.size.

Returns:

num_pages
the number of pages if successful
 model = Sketchup.active_model
 pages = model.pages
 status = pages.add "Page 1"
 status = pages.add "Page 2"
 num = pages.count

Pages.eachSketchUp 6.0+

The each method is used to iterate through pages.

Arguments:

page
Variables that will hold each page as it is found.

Returns:

nil
 model = Sketchup.active_model
 pages = model.pages
 status = pages.add "Page 1"
 status = pages.add "Page 2"
 pages.each {|page| UI.messagebox page}

Pages.eraseSketchUp 6.0+

The erase method is used to remove a page from the collection.

Arguments:

page
The page you wish to delete.

Returns:

true if successful, false if unsuccessful.
 status = Sketchup.active_model.pages.erase my_page

Pages.parentSketchUp 6.0+

The parent method is used to determine the model for the Pages collection.

Returns:

model
the model that contains the pages if successful
 model = Sketchup.active_model
 pages = model.pages
 status = pages.add "Page 1"
 status = pages.add "Page 2"
 model = pages.parent

Pages.remove_frame_change_observerSketchUp 6.0+

The remove_frame_change_observer method is used to remove a frame change observer

The argument is the number returned from the call to add_frame_change_observer.

Arguments:

observer_id
The unique id returned by add_frame_change_observer

Returns:

success
true if successful
 Sketchup::Pages.remove_frame_change_observer id

Pages.remove_observerSketchUp 6.0+

The remove_observer method is used to remove an observer from the current object. See the PagesObserver interface for more details.

Arguments:

observer
An observer.

Returns:

true if successful, false if unsuccessful.
 pages = Sketchup.active_model.pages
 status = pages.remove_observer observer

Pages.selected_pageSketchUp 6.0+

The selected_page method is used to retrieve the currently selected page.

Returns:

page
the currently selected Page object if successful
 model = Sketchup.active_model
 pages = model.pages
 status = pages.add "Page 1"
 status = pages.add "Page 2"
 page = pages.selected_page

Pages.selected_page=SketchUp 6.0+

The selected_page method is used to set the currently selected page. Once you set this, SketchUp will animate to that page as if the user had clicked on its scene tab.

Returns:

status
true if successful
 model = Sketchup.active_model
 pages = model.pages
 status = pages.add "Page 1"
 status = pages.add "Page 2"
 pages.selected_page = model.pages[1]

Pages.show_frame_atSketchUp 6.0+

The show_frame_at method is used to show a frame in animation (of the slide show) at a given time in seconds.

Arguments:

seconds
The time in seconds.

Returns:

nil
 model = Sketchup.active_model
 pages = model.pages
 status = pages.add "Page 1"
 status = pages.add "Page 2"
 status = pages.show_frame_at 10

Pages.sizeSketchUp 6.0+

The size method is used to retrieve the number of pages.

Returns:

num_pages
the number of pages
 model = Sketchup.active_model
 pages = model.pages
 status = pages.add "Page 1"
 status = pages.add "Page 2"
 size = pages.size

Pages.slideshow_timeSketchUp 6.0+

The slideshow_time method is used to get the amount of time that a slideshow of all of the pages will take. This takes into account the transition time for each Page and the amount of time that each Page is displayed.

Returns:

status
true if successful
 pages = Sketchup.active_model.pages
 time = pages.slideshow_time