class Pages

Parent: Entity | Class Index
Methods:add_frame_change_observer, remove_frame_change_observer, [], add, count, each, parent, selected_page, show_frame_at, size, slideshow_time |
Sample Code:pagestests.rb |

A collection of Pages in a model.

Class Methods

add_frame_change_observer
The add_frame_change_observer method is used to add a new frame change observer for animations
Syntax:
pages.add_frame_change_observer object
Arguments:
object - an object that implements the frameChange method
Return Value:
Comments:
The argument is an object that implements a method frameChange with the following form: def frameChange(fromPage, toPage, parameter) ... end 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 parameter between 0 and 1 that tell you the percentage of the way between the two pages. The method returns an integer that can be used to remove the observer
Example:
number = Sketchup::Pages.add_frame_change_observer FrameChangeObserver.new --------------- class FrameChangeObserver def frameChange(fromPage, toPage, parameter) # Just show the information #s1 = fromPage ? fromPage.name : "NULL" #s2 = toPage ? toPage.name : "NULL" #puts "#{s1} to #{s2} at #{parameter}" if( parameter < 1.0e-3 ) get_entities_to_move(toPage) else move_entities parameter end end

remove_frame_change_observer
The remove_frame_change_observer method is used to remove a frame change observer
Syntax:
pages.remove_frame_change_observer(observer_num)
Arguments:
Return Value:
Comments:
The argument is the number returned from the call to add_frame_change_observer.
Example:
number = Sketchup::Pages.remove_frame_change_observer

Instance Methods

[]
The [] method retrieves a page by either name or index.
Syntax:
page = pages[index] page = pages["name"]
Arguments:
index - the index for a specific page name - the name of the specific page
Return Value:
page - a Page object if successful
Comments:
Example:
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

add
The add method is used to add a empty Page object
Syntax:
page = pages.add page = pages.add name page = pages.add name, flags
Arguments:
name - the name of the specific page flags -
Return Value:
Comments:
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 flags is given, it controls which properties are saved with the new Page. See Page.update for a description of the flags that can be set.
Example:
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

count
The count method is an alias for size. See also Page.size
Syntax:
num_pages = pages.count
Arguments:
Return Value:
num_pages - the number of pages if successful
Comments:
Example:
model = Sketchup.active_model pages = model.pages status = pages.add "Page 1" status = pages.add "Page 2" num = pages.count

each
The each method is used to iterate through pages.
Syntax:
pages.each {| page |...}
Arguments:
page – variables that will hold each page as it is found.
Return Value:
Comments:
Example:
model = Sketchup.active_model pages = model.pages status = pages.add "Page 1" status = pages.add "Page 2" pages.each {|page| UI.messagebox page}

parent
The parent method is used to determine the model for the pages.
Syntax:
model = pages.parent
Arguments:
Return Value:
model - the model that contains the pages if successful
Comments:
Example:
model = Sketchup.active_model pages = model.pages status = pages.add "Page 1" status = pages.add "Page 2" model = pages.parent

selected_page
The selected_page method is used to retrieve the currently selected page.
Syntax:
page = pages.selected_page
Arguments:
Return Value:
page - the currently selected Page object if successful
Comments:
Example:
model = Sketchup.active_model pages = model.pages status = pages.add "Page 1" status = pages.add "Page 2" page = pages.selected_page

show_frame_at
The show_frame_at method is used to show a frame in animation (of the slide show) at a given time in seconds.
Syntax:
pages.show_frame_at time_in_seconds
Arguments:
time_in_seconds - the time in seconds
Return Value:
Comments:
Example:
model = Sketchup.active_model pages = model.pages status = pages.add "Page 1" status = pages.add "Page 2" status = pages.show_frame_at 10

size
The size method is used to retrieve the number of pages.
Syntax:
num_pages = pages.size
Arguments:
Return Value:
num_pages - the number of pages
Comments:
Example:
model = Sketchup.active_model pages = model.pages status = pages.add "Page 1" status = pages.add "Page 2" size = pages.size

slideshow_time
The slideshow_time method is used to retrieve the amount of time that a slideshow of all of the pages will take.
Syntax:
time = pages.slideshow_time
Arguments:
Return Value:
time - the amount of time that a slide show will take if successful
Comments:
This takes into account the transition time for each Page and the amount of time that each Page is displayed.
Example:
model = Sketchup.active_model pages = model.pages status = pages.add "Page 1" status = pages.add "Page 2" status = pages.show_frame_at 10 time = pages.slideshow_time