ModraUp Ruby API Documentation Ruby API Reference

Class: ModraUp::Pages

Inherits:
ModraUp::Entity show all
Includes:
Enumerable

Overview

The model's scene pages table. Obtain it from ModraUp::Model#pages. It includes Enumerable.

Examples:

pages = ModraUp.active_model.pages
pages.add("Plan")
pages.selected_page.name  #=> "Plan"

Class Method Summary # collapse

Instance Method Summary # collapse

Inherited from ModraUp::Entity

  • #typename ⇒ String
    Type name (e.g., Face / Edge / Group).
  • #entityID ⇒ Integer
    Entity ID within the current session: A small integer starting from 1 that increments and remains constant for the lifetime of the entity, unchanged by undo/redo operations. This ID is not preserved when saving the file; it will be renumbered upon reopening the model. For cross-session identification, use #persistent_id. Copied entities will receive new IDs.
  • #persistent_id ⇒ Integer
    Number assigned with the model: A unique, incrementing small integer starting from 1 that persists across model saves and reloads, independent of #entityID. Copied entities receive new numbers, and deleted entities do not reuse their numbers. Edges, faces, vertices, curves, groups, component instances/definitions, dimensions, leader lines/points, section planes, materials, layers, layer folders, and drawing sheets have assigned numbers; all others (rings, EdgeUses, attribute dictionaries, line types, sets, etc.) return 0.
  • #model ⇒ ModraUp::Model
    The model it belongs to.
  • #to_s ⇒ String
    String form. Returns "#<Deleted Entity>” when the entity has been deleted.
  • #inspect ⇒ String
    Same as #to_s.
  • #attribute_dictionaries ⇒ ModraUp::AttributeDictionaries, nil
    Collection of attribute dictionaries. Returns nil (evaluates to false) if there are no dictionaries.
  • #attribute_dictionary(name) ⇒ ModraUp::AttributeDictionary, nil
    Retrieve an attribute dictionary by name. If none exists, return nil; if create is true, create an empty dictionary. ModraUp::Loop / ModraUp::EdgeUse / ModraUp::Curve always return nil.
  • #valid? ⇒ Boolean
    Returns true if the entity is valid, meaning it has not been deleted from the model. Revoked entities are false; even if new geometry is drawn occupying its original position, this object remains an invalid entity (still false). Repeating the action to restore it makes it valid again.
  • #deleted? ⇒ Boolean
    Opposite of #valid?.
  • #set_attribute(dict_name, key, value) ⇒ Object
    Write attribute values. Materials, groups, component instances, faces, and edges are supported. When dict_name and key are Symbols, they are converted to strings. The type of data written is the same type that will be read back.
  • #get_attribute(dict_name, key, default = nil) ⇒ Object
    Read the attribute. If dict_name and key are Symbols, convert them to strings (similar to SketchUp). If the dictionary or key does not exist, return default. The return value type is the same as what is written by #set_attribute.
  • #delete_attribute(dict_name) ⇒ Boolean
    Delete a key, or delete the entire dictionary when the key is omitted.

Class Method Details

Pages.add_frame_change_observer(observer) ⇒ Integer

Register a global ModraUp::FrameChangeObserver. The frameChange method is called when switching scenes. Returns an integer ID to be passed to ModraUp::Pages.remove_frame_change_observer.

Parameters:

  • observer (ModraUp::FrameChangeObserver)

Returns:

  • (Integer)

Examples:

id = ModraUp::Pages.add_frame_change_observer(ModraUp::FrameChangeObserver.new)
ModraUp::Pages.remove_frame_change_observer(id)

Pages.remove_frame_change_observer(id) ⇒ Boolean

Remove the observer by the id returned from ModraUp::Pages.add_frame_change_observer.

Parameters:

  • id (Integer)

Returns:

  • (Boolean)

Examples:

id = ModraUp::Pages.add_frame_change_observer(ModraUp::FrameChangeObserver.new)
ModraUp::Pages.remove_frame_change_observer(id)

Instance Method Details

pages[index] ⇒ ModraUp::Page, nilpages[name] ⇒ ModraUp::Page, nil

Retrieve the scene by index or name. Return nil if none exists.

Parameters:

  • index (Integer, String)

Returns:

  • (ModraUp::Page, nil)

Examples:

pages = ModraUp.active_model.pages
pages.add("Plan")
pages["Plan"].name  #=> "Plan"

pages.add ⇒ ModraUp::Pagepages.add(name) ⇒ ModraUp::Pagepages.add(name, flags) ⇒ ModraUp::Pagepages.add(name, flags, index) ⇒ ModraUp::Page

Add a new page using the current camera and layer visibility state, and select it. If the name is a duplicate, it will be renamed to avoid conflict. Omitting flags sets it to PAGE_USE_ALL.

Parameters:

  • name (String, nil)
  • flags (Integer) PAGE_USE_CAMERA flag
  • index (Integer) The new scene's position (starting at 0); if out of range, it is added to the end.

Returns:

  • (ModraUp::Page)

Examples:

page = ModraUp.active_model.pages.add("Plan")
page.name  #=> "Plan"

pages.each {|page| ... } ⇒ selfpages.each ⇒ Enumerator

Iterate through the scene pages.

Returns:

  • (self, Enumerator)

Yields:

  • @yieldparam [ModraUp::Page] page

Examples:

ModraUp.active_model.pages.each { |page| page.name }

pages.erase(page) ⇒ Boolean

Delete a page.

Parameters:

  • page (ModraUp::Page)

Returns:

  • (Boolean)

Examples:

pages = ModraUp.active_model.pages
page = pages.add("Temp")
pages.erase(page)

pages.size ⇒ Integer

Number of scenes.

Returns:

  • (Integer)

Examples:

ModraUp.active_model.pages.size

pages.parent ⇒ ModraUp::Model

The model it belongs to.

Returns:

  • (ModraUp::Model)

Examples:

ModraUp.active_model.pages.parent == ModraUp.active_model

pages.selected_page ⇒ ModraUp::Page, nil

The currently selected page. Returns nil if no page is selected.

Returns:

  • (ModraUp::Page, nil)

Examples:

pages = ModraUp.active_model.pages
pages.add("Plan")
pages.selected_page.name  #=> "Plan"

pages.selected_page=(page) ⇒ Boolean

Select the scene and apply its camera, shadows, and layer visibility immediately. No transition animation is played.

The camera read immediately after setting is the camera of that scene. The scene tag in the interface and ModraUp.send_action("pageNext:") update with the scene when model.options["PageOptions"] is set to play a transition in the view › animation.

Parameters:

  • page (ModraUp::Page)

Returns:

  • (Boolean)
Note: ModraUp extension. SketchUp animates the scene transition when it is enabled; this host always switches immediately.

Examples:

pages = ModraUp.active_model.pages
a = pages.add("A")
b = pages.add("B")
pages.selected_page = a

pages.add_observer(observer) ⇒ Boolean

Register a ModraUp::PagesObserver. Adding the same object a second time returns false.

Parameters:

  • observer (ModraUp::PagesObserver)

Returns:

  • (Boolean)

Examples:

ModraUp.active_model.pages.add_observer(ModraUp::PagesObserver.new)

pages.remove_observer(observer) ⇒ Boolean

Remove observers from the scene table.

Parameters:

  • observer (ModraUp::PagesObserver)

Returns:

  • (Boolean)

Examples:

pages = ModraUp.active_model.pages
obs = ModraUp::PagesObserver.new
pages.add_observer(obs)
pages.remove_observer(obs)

pages.unique_name(base_name) ⇒ String

Generate a unique scene name based on the root name. If the name is already in use, append a number to it.

Parameters:

  • base_name (String)

Returns:

  • (String)
Note: ModraUp extension. In case of conflict, it is "Joe1", not SketchUp's "Joe 2".

Examples:

pages = ModraUp.active_model.pages
pages.add("Joe")
pages.unique_name("Joe")  #=> "Joe1"

pages.slideshow_time ⇒ Float

Slide Show Total Time: Includes the seconds for transitions and holds of scenes that are included in the animation. If a scene's own time is negative, it defaults to the model's default time (ModraUp::Page#include_in_animation? / model.options["PageOptions"] / ["SlideshowOptions"]). If scene transitions are disabled, the transition time is counted as 0.

Returns:

  • (Float)

Examples:

ModraUp.active_model.pages.slideshow_time

pages.show_frame_at(seconds) ⇒ Array(ModraUp::Page, Float), nil

Display the slide at the frame after seconds seconds: Select the scene at that moment and apply it. The camera position is set to the corresponding position from the previous scene to the current one (consistent with the easing during playback). The timeline is as follows: the first scene stays for the delay time, followed by each scene transitioning and then staying, and finally transitioning back to the start from the first scene, with a total length of #slideshow_time; scenes outside the range are ignored. Only scenes where ModraUp::Page#include_in_animation? returns true are considered.

Return the displayed scene and the transition progress (0.0–1.0, 1.0 for staying). If no scenes are included in the animation, return nil. Trigger ModraUp::FrameChangeObserver#frameChange.

Parameters:

  • seconds (Numeric)

Returns:

  • (Array(ModraUp::Page, Float), nil)

Raises:

  • [TypeError] seconds is not a number

Examples:

pages = ModraUp.active_model.pages
pages.add("Page 1")
pages.add("Page 2")
page, ratio = pages.show_frame_at(1.8)

pages.reorder(page, new_index) ⇒ nil

Move the scene to index new_index (starting at 0), keeping the selected scene unchanged.

Parameters:

  • page (ModraUp::Page)
  • new_index (Integer)

Returns:

  • (nil)

Raises:

  • [TypeError] page is not a ModraUp::Page
  • [ArgumentError] page is not part of this model or has been deleted.
  • [ IndexError ] new_index is out of range

Examples:

pages = ModraUp.active_model.pages
a = pages.add("A")
pages.add("B")
pages.reorder(a, 1)