class Sketchup::OptionsProvider

An OptionsProvider class provides various kinds of options on a {Sketchup::Model}. You get an OptionsProvider from the {Sketchup::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

Public Instance Methods

[](arg) click to toggle source

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

@example

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

@overload [](index)

@param index         The index for a specific key.
@return              value - the value if successful

@overload [](name)

@param name          The name of the specific key.
@return              value - the value if successful

@version SketchUp 6.0

# File lib/sketchup-api-stubs/stubs/Sketchup/OptionsProvider.rb, line 47
def [](arg)
end
[]=(key, value) click to toggle source

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

Creates a new attribute for the given key if needed.

@example

option = provider[1]=10

@param key

The valid key.

@param value

The value to be set.

@return value - the value that was set if successful, or false

if unsuccessful.

@version SketchUp 6.0

# File lib/sketchup-api-stubs/stubs/Sketchup/OptionsProvider.rb, line 67
def []=(key, value)
end
add_observer(observer) click to toggle source

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

@example

status = object.add_observer observer

@param observer

An observer.

@return true if successful, false if unsuccessful.

@version SketchUp 6.0

# File lib/sketchup-api-stubs/stubs/Sketchup/OptionsProvider.rb, line 81
def add_observer(observer)
end
count() click to toggle source

@example

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

@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}.

@return [Integer]

@see length

@version SketchUp 6.0

# File lib/sketchup-api-stubs/stubs/Sketchup/OptionsProvider.rb, line 98
def count
end
each() click to toggle source

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

@example

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

@return [nil]

@see each_key

@version SketchUp 6.0

@yield [key, value]

@yieldparam [String] key

@yieldparam [Object] value

# File lib/sketchup-api-stubs/stubs/Sketchup/OptionsProvider.rb, line 119
def each
end
each_key() click to toggle source

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

@example

provider.each_key { |key| puts key }

@return [nil]

@version SketchUp 6.0

@yield [key]

@yieldparam [String] key

# File lib/sketchup-api-stubs/stubs/Sketchup/OptionsProvider.rb, line 134
def each_key
end
each_pair() click to toggle source

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

@example

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

@return [nil]

@see each_key

@version SketchUp 6.0

@yield [key, value]

@yieldparam [String] key

@yieldparam [Object] value

# File lib/sketchup-api-stubs/stubs/Sketchup/OptionsProvider.rb, line 155
def each_pair
end
each_value() click to toggle source

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

Throws an exception if there are no keys.

@example

provider.each_value { |value| puts value }

@return nil

@version SketchUp 6.0

@yield [value] A variable that will hold each value as they are found.

# File lib/sketchup-api-stubs/stubs/Sketchup/OptionsProvider.rb, line 171
def each_value
end
has_key?(name) click to toggle source

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

@example

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

@param [String] name

The name of the key you are looking for.

@return [Boolean]

@see key?

@version SketchUp 6.0

# File lib/sketchup-api-stubs/stubs/Sketchup/OptionsProvider.rb, line 189
def has_key?(name)
end
key?(name) click to toggle source

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

@example

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

@param [String] name

The name of the key you are looking for.

@return [Boolean]

@see has_key?

@version SketchUp 6.0

# File lib/sketchup-api-stubs/stubs/Sketchup/OptionsProvider.rb, line 208
def key?(name)
end
keys() click to toggle source

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

@example

keys = provider.keys
key = keys[0]
if (key)
  UI.messagebox key
else
  UI.messagebox "Failure"
end

@return keys - an array of keys within the options provider if

successful

@version SketchUp 6.0

# File lib/sketchup-api-stubs/stubs/Sketchup/OptionsProvider.rb, line 226
def keys
end
length() click to toggle source

The {#length} method is an alias of {#size}.

@example

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

@return [Integer]

@see size

@version SketchUp 2014

# File lib/sketchup-api-stubs/stubs/Sketchup/OptionsProvider.rb, line 240
def length
end
name() click to toggle source

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

@example

name = provider.name

@return name - the name of the options provider if successful

@version SketchUp 6.0

# File lib/sketchup-api-stubs/stubs/Sketchup/OptionsProvider.rb, line 251
def name
end
remove_observer(observer) click to toggle source

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

@example

status = object.remove_observer observer

@param observer

An observer.

@return true if successful, false if unsuccessful.

@version SketchUp 6.0

# File lib/sketchup-api-stubs/stubs/Sketchup/OptionsProvider.rb, line 266
def remove_observer(observer)
end
size() click to toggle source

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

@example

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

@return [Integer]

@see length

@version SketchUp 6.0

# File lib/sketchup-api-stubs/stubs/Sketchup/OptionsProvider.rb, line 281
def size
end