Class: Sketchup::Pages

Inherits:
Entity
  • Object
show all
Includes:
Enumerable

Overview

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.

Examples:

model = Sketchup.active_model
pages = model.pages

Version:

  • SketchUp 6.0

Class Method Summary # collapse

Instance Method Summary # collapse

Methods inherited from Entity

#attribute_dictionaries, #attribute_dictionary, #delete_attribute, #deleted?, #entityID, #get_attribute, #inspect, #model, #persistent_id, #set_attribute, #to_s, #typename, #valid?

Class Method Details

.add_frame_change_observer(object) ⇒ Integer

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 method returns an integer id that can be stored and later used to remove the observer with the remove_frame_change_observer method.

Examples:

class MyFrameChangeObserver
  def frameChange(from_page, to_page, percent_done)
    puts "From page #{from_page.name} to #{to_page.name} (#{percent_done * 100}%)"
  end
end
id = Sketchup::Pages.add_frame_change_observer(MyFrameChangeObserver.new)

Returns A unique id of the observer

Parameters:

Returns:

  • (Integer)

    A unique id of the observer

See Also:

Version:

  • SketchUp 6.0

.remove_frame_change_observer(observer_id) ⇒ Boolean

The #remove_frame_change_observer method is used to remove a frame change observer

Examples:

Sketchup::Pages.remove_frame_change_observer(id)

Parameters:

Returns:

  • (Boolean)

Version:

  • SketchUp 6.0

Instance Method Details

#[](index_or_name) ⇒ Object

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

Examples:

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

Returns page - a Page object if successful

Parameters:

  • index_or_name

    The index or the string name of the specific page.

Returns:

  • page - a Page object if successful

Version:

  • SketchUp 6.0

#add(name, flags, index) ⇒ Object

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.

Examples:

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

Returns nil

Parameters:

  • name

    The name of the specific page.

  • flags (optional)

    Bit flags in integer form.

  • index (optional)

    Index of where to inset.

Returns:

  • nil

Version:

  • SketchUp 6.0

#add_matchphoto_page(image_name, camera, page_name) ⇒ Object

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.

Examples:

pages = Sketchup.active_model.pages
page = pages.add_matchphoto_page "Test"

Returns page - the new photomatch page.

Parameters:

  • image_name

    String image name.

  • camera (optional)

    Camera object.

  • page_name (optional)

    String page name.

Returns:

  • page - the new photomatch page.

Version:

  • SketchUp 7.0

#add_observer(observer) ⇒ Object

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

Examples:

pages = Sketchup.active_model.pages
status = pages.add_observer observer

Returns true if successful, false if unsuccessful.

Parameters:

  • observer

    An observer.

Returns:

  • true if successful, false if unsuccessful.

Version:

  • SketchUp 6.0

#countInteger

Note:

Since SketchUp 2014 the count method is inherited from Ruby's Enumable mix-in module. Prior to that the #count method is an alias for #length.

Examples:

pages = Sketchup.active_model.pages
pages.add('Page 1')
pages.add('Page 2')
number = pages.count

Returns:

  • (Integer)

See Also:

Version:

  • SketchUp 6.0

#each {|page| ... } ⇒ Object

The each method is used to iterate through pages.

Examples:

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

Yields:

  • (page)

    Variables that will hold each page as it is found.

Returns:

  • nil

Version:

  • SketchUp 6.0

#erase(page) ⇒ Object

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

Examples:

page = Sketchup.active_model.pages.add('Hello World')
Sketchup.active_model.pages.erase(page)

Returns true if successful, false if unsuccessful.

Parameters:

  • page

    The page you wish to delete.

Returns:

  • true if successful, false if unsuccessful.

Version:

  • SketchUp 6.0

#lengthInteger

The #length method is an alias for #size.

Examples:

pages = Sketchup.active_model.pages
pages.add('Page 1')
pages.add('Page 2')
number = pages.length

Returns:

  • (Integer)

See Also:

Version:

  • SketchUp 2014

#parentObject

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

Examples:

model = Sketchup.active_model
pages = model.pages
status = pages.add "Page 1"
status = pages.add "Page 2"
model = pages.parent

Returns:

  • model - the model that contains the pages if successful

Version:

  • SketchUp 6.0

#remove_observer(observer) ⇒ Object

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

Examples:

pages = Sketchup.active_model.pages
status = pages.remove_observer observer

Returns true if successful, false if unsuccessful.

Parameters:

  • observer

    An observer.

Returns:

  • true if successful, false if unsuccessful.

Version:

  • SketchUp 6.0

#selected_pageObject

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

Examples:

model = Sketchup.active_model
pages = model.pages
status = pages.add "Page 1"
status = pages.add "Page 2"
page = pages.selected_page

Returns:

  • page - the currently selected Page object if successful

Version:

  • SketchUp 6.0

#selected_page=(page) ⇒ Object

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.

Examples:

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

Returns status - true if successful

Parameters:

Returns:

  • status - true if successful

Version:

  • SketchUp 6.0

#show_frame_at(seconds) ⇒ Object

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

Examples:

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

Returns nil

Parameters:

  • seconds

    The time in seconds.

Returns:

  • nil

Version:

  • SketchUp 6.0

#sizeInteger

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

Examples:

pages = Sketchup.active_model.pages
pages.add('Page 1')
pages.add('Page 2')
number = pages.size

Returns:

  • (Integer)

See Also:

Version:

  • SketchUp 6.0

#slideshow_timeObject

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.

Examples:

pages = Sketchup.active_model.pages
time = pages.slideshow_time

Returns:

  • status - true if successful

Version:

  • SketchUp 6.0