My favorites | English | Sign in

Faster apps faster - GWT 2.0 with Speed Tracer New!

Google SketchUp Ruby API

OptionsProvider

class

Parent: Object

Introduction

SketchUp 6.0+

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.

Methods

OptionsProvider.[]SketchUp 6.0+

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

Arguments:

index
The index for a specific key.
name
The name of the specific key.

Returns:

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

OptionsProvider.[]=SketchUp 6.0+

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

Creates a new attribute for the given key if needed.

Arguments:

key
The valid key.
value
The value to be set.

Returns:

value
the value that was set if successful, or false if unsuccessful.
 option = provider[1]=10

OptionsProvider.add_observerSketchUp 6.0+

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

Arguments:

observer
An observer.

Returns:

true if successful, false if unsuccessful.
 status = object.add_observer observer

OptionsProvider.countSketchUp 6.0+

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

Returns:

size
the size of the options provider if successful
 count = optionsprovider.count

OptionsProvider.eachSketchUp 6.0+

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

Throws an exception if there are no keys.

Arguments:

key,
value Variables that will hold each key and value as they are found.

Returns:

nil
 # Retrieves each key
 provider.each { |key, value| UI.messagebox key }
 # Retrieves each corresponding value
 provider.each { |key, value| UI.messagebox value }

OptionsProvider.each_keySketchUp 6.0+

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

Throws an exception if there are no keys.

Arguments:

key
A variable that will hold each key as they are found.

Returns:

nil
 provider.each_key { |key| UI.messagebox key }

OptionsProvider.each_pairSketchUp 6.0+

An alias for each. See OptionsProvider.each

Throws an exception if there are no keys.

Arguments:

key,
value Variables that will hold each key and value as they are found.

Returns:

nil
 # Retrieves each key
 provider.each_pair { |key, value| UI.messagebox key }

OptionsProvider.each_valueSketchUp 6.0+

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

Throws an exception if there are no keys.

Arguments:

value
A variable that will hold each value as they are found.

Returns:

nil
 provider.each_value { |value| UI.messagebox value }

OptionsProvider.has_key?SketchUp 6.0+

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

Arguments:

name
The name of the key you are looking for.

Returns:

status
true if the key exists, false if the key does not exist.
 status = provider.has_key? "PageOptions"
 if (status)
   UI.messagebox status
 else
   UI.messagebox "Failure"
 end

OptionsProvider.key?SketchUp 6.0+

The key? method is used to determine if the options provider has a specific key. This method is the same as has_key? See also OptionsManager.has_key

Arguments:

name
The name of the key you are looking for.

Returns:

status
true if the key exists, false if the key does not exist.
 status = provider.key? "name"

OptionsProvider.keysSketchUp 6.0+

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

Returns:

keys
an array of keys within the options provider if successful
 keys = provider.keys
 key = keys[0]
 if (key)
   UI.messagebox key
 else
   UI.messagebox "Failure"
 end

OptionsProvider.nameSketchUp 6.0+

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

Returns:

name
the name of the options provider if successful

 name = provider.name

OptionsProvider.remove_observerSketchUp 6.0+

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

Arguments:

observer
An observer.

Returns:

true if successful, false if unsuccessful.
 status = object.remove_observer observer

OptionsProvider.sizeSketchUp 6.0+

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

Returns:

size
the size of the options provider if successful
 size = optionsprovider.size