[Ruby] RfE: Sketchup::Page animation query / setter methods needed

:white_check_mark: DONE !

FYI,… Finally, … the API has been updated for version 2018 and higher …

… both a query method and a setter method have been added to the Sketchup::Page class.

Sketchup::Page.include_in_animation=

Sketchup::Page.include_in_animation?


Old request ... (click to expand) ...

Please implement Ruby scene instance methods for the Sketchup::Page class:

Sketchup::Page # use_in_animation?

[Boolean] Return true || false if this scene page is set to be included in animations.

Sketchup::Page # use_in_animation=( flag = true )

(perhaps alias: use_in_animation)
@flag [Boolean] Set if this scene page is to be included in animations. (Default is true.)
Return result of setting.


Testing on SU2015 shows that the “include in animation” flag is applied or deactivated immediately, with no need to manually cause a scene page “Update”.

Therefore, I have not requested another integer bit code (128) for the Sketchup::Page # update() method.
But if I am in error, and a new bit code is really needed, then of course add it, also.

Oh wow…

… I just realized there always was a workaround for the boolean query method. (Depending upon …)

Example:

def page_used_in_animation?( page )
#
# Returns false if page's label is the page's name
#  surrounded by parenthesis, otherwise true.
#  ( Works even if user manually named the scene
#    page using parenthesis around the name. )
  #
  if page.is_a?( Sketchup::Page )
    if page.label.length - page.name.length == 2 &&
    page.label[0,1] == '(' && page.label[-1,1] == ')'
      return false
    else
      return true
    end
  else
    fail(
      TypeError,
      "Sketchup::Page instance expected as argument.",
      caller
    )
  end
  #
end

EDIT: Fixed code example. (Had boolean result reversed.)

… but this depends upon scene page labels being surrounded by parenthesis when excluded from animation, in all language builds.

?

1 Like

:white_check_mark: DONE !

FYI,… Finally, after 2.5 years … the API has been updated for version 2018 and higher …

… both a query method and a setter method have been added to the Sketchup::Page class.

Sketchup::Page.include_in_animation=

Sketchup::Page.include_in_animation?

1 Like