123456789_123456789_123456789_123456789_123456789_

Class: Sketchup::OptionsProvider

Relationships
Super Chains via Extension / Inclusion / Inheritance
Instance Chain:
self, Enumerable
Inherits: Object

Overview

An OptionsProvider class provides various kinds of options on a Model. You get an OptionsProvider from the OptionsManager. The options are given as name/value pairs.

List of keys added in different SketchUp versions:

UnitsOptions
  • AreaUnit (SketchUp 2019.2)

  • VolumeUnit (SketchUp 2019.2)

  • AreaPrecision (SketchUp 2020.0)

  • VolumePrecision (SketchUp 2020.0)

The AreaUnit and VolumeUnit options in UnitsOptions only applies if the UnitFormat is Length::Decimal.

Version:

  • SketchUp 6.0

Instance Method Summary

Instance Method Details

#[](index) ⇒ Object #[](name) ⇒ Object

The [] method is used to get a value by name or index of the key.

Examples:

model = Sketchup.active_model
manager = model.options
provider = manager[0]
# Retrieves the provider at index 1
option = provider[1]

Overloads:

  • #[](index) ⇒ Object

    Parameters:

    • index

      The index for a specific key.

    Returns:

    • value - the value if successful

  • #[](name) ⇒ Object

    Parameters:

    • name

      The name of the specific key.

    Returns:

    • value - the value if successful

Version:

  • SketchUp 6.0

#[]=(key, value) ⇒ Object

The []= method is used to set the value of a specific key.

Creates a new attribute for the given key if needed.

Examples:

option = provider[1]=10

Parameters:

  • key

    The valid key.

  • value

    The value to be set.

Returns:

  • value - the value that was set if successful, or false if unsuccessful.

Version:

  • SketchUp 6.0

#add_observer(observer) ⇒ Object

The add_observer method is used to add an observer to the current object.

Examples:

status = object.add_observer observer

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 Enumerable mix-in module. Prior to that the #count method is an alias for #length.

Examples:

optionsprovider = Sketchup.active_model.options['UnitsOptions']
number = optionsprovider.count

See Also:

Version:

  • SketchUp 6.0

#each {|key, value| ... } ⇒ nil

The #each method is used to iterate through all of the options.

Examples:

model = Sketchup.active_model
provider = model.options['UnitsOptions']
provider.each { |key, value| puts "#{key} = #{value}" }

Yield Parameters:

See Also:

Version:

  • SketchUp 6.0

#each_key {|key| ... } ⇒ nil

The #each_key method is used to iterate through all of the attribute keys.

Examples:

provider.each_key { |key| puts key }

Yield Parameters:

Version:

  • SketchUp 6.0

#each_pair {|key, value| ... } ⇒ nil

The #each method is used to iterate through all of the options.

Examples:

model = Sketchup.active_model
provider = model.options['UnitsOptions']
provider.each { |key, value| puts "#{key} = #{value}" }

Yield Parameters:

See Also:

Version:

  • SketchUp 6.0

#each_value {|value| ... } ⇒ nil

The #each_value method is used to iterate through all of the attribute values.

Examples:

provider.each_value { |value| puts value }

Yield Parameters:

  • value (Object)

Version:

  • SketchUp 6.0

#has_key?(name) ⇒ Boolean

The #has_key? method is an alias for #key?.

Examples:

model = Sketchup.active_model
provider = model.options['UnitsOptions']
p provider.has_key?("LengthFormat")

Parameters:

  • name (String)

    The name of the key you are looking for.

See Also:

Version:

  • SketchUp 6.0

#key?(name) ⇒ Boolean

The #key? method is used to determine if the options provider has a specific key.

Examples:

model = Sketchup.active_model
provider = model.options['UnitsOptions']
p provider.key?("LengthFormat")

Parameters:

  • name (String)

    The name of the key you are looking for.

See Also:

Version:

  • SketchUp 6.0

#keysObject

The #keys method is used to retrieve an array with all of the attribute keys.

Examples:

keys = provider.keys
key = keys[0]

Returns:

  • keys - an array of keys within the options provider if successful

Version:

  • SketchUp 6.0

#lengthInteger

The #length method is an alias of #size.

Examples:

optionsprovider = Sketchup.active_model.options['UnitsOptions']
number = optionsprovider.length

See Also:

Version:

  • SketchUp 2014

#nameObject

The name method is used to retrieve the name of an options provider.

Examples:

name = provider.name

Returns:

  • name - the name of the options provider if successful

Version:

  • SketchUp 6.0

#remove_observer(observer) ⇒ Object

The remove_observer method is used to remove an observer from the current object.

Examples:

status = object.remove_observer observer

Parameters:

  • observer

    An observer.

Returns:

  • true if successful, false if unsuccessful.

Version:

  • SketchUp 6.0

#sizeInteger

The #size method is used to retrieve the size (number of elements) of an options provider.

Examples:

optionsprovider = Sketchup.active_model.options['UnitsOptions']
number = optionsprovider.size

See Also:

Version:

  • SketchUp 6.0