Class: Sketchup::AttributeDictionaries

Inherits:
Entity
  • Object
show all
Includes:
Enumerable

Overview

The AttributeDictionaries class is a collection of all of the AttributeDictionary objects that are attached to a given Entity object.

The Entity class is a popular parent class in SketchUp, meaning you can attach AttributeDictionaries to almost anything, from geometric items like edges and faces and components to more conceptual things like pages or materials.

You access this class not by performing an AttributeDictionaries.new but by grabbing a handle from an existing entity.

Examples:

# Grab the first entity from the model.
my_layer = Sketchup.active_model.entities[0]

# Grab a handle to its attribute dictionaries.
attrdicts = my_layer.attribute_dictionaries

Version:

  • SketchUp 6.0

Instance Method Summary # collapse

Methods inherited from Entity

#add_observer, #attribute_dictionaries, #attribute_dictionary, #delete_attribute, #deleted?, #entityID, #get_attribute, #inspect, #model, #parent, #persistent_id, #remove_observer, #set_attribute, #to_s, #typename, #valid?

Instance Method Details

#[](key) ⇒ Object

Get an AttributeDictionary by name. Returns nil if there is none with the given name.

Examples:

model = Sketchup.active_model
attrdicts = model.attribute_dictionaries
# Iterates through all dictionaries and prints to screen.
dict = attrdicts['my_dictionary']
if dict
  UI.messagebox("Found: " + dict.to_s)
else
  UI.messagebox("No dictionary found.")
end

Returns dictionary - the dictionary

Parameters:

  • key

    The name of the attribute dictionary.

Returns:

  • dictionary - the dictionary

Version:

  • SketchUp 6.0

#countInteger

The count method is inherited from the Enumerable mix-in module.

Examples:

model = Sketchup.active_model
model.set_attribute('Example', 'Hello', 'World')
dictionaries = model.attribute_dictionaries
number = dictionaries.count

Returns:

  • (Integer)

See Also:

Version:

  • SketchUp 2014

#delete(key_or_dict) ⇒ Object

The delete method destroys a given AttributeDictionary. This AttributeDictionary can be passed directly or identified by its string name.

Examples:

model = Sketchup.active_model
attrdicts = model.attribute_dictionaries
# Deletes a dictionary called 'my_dictionary'
attrdicts.delete 'my_dictionary'

Returns dictionaries - the modified AttributeDictionaries object

Parameters:

  • key_or_dict

    The name of the attribute dictionary to delete, or the dictionary object itself.

Returns:

  • dictionaries - the modified AttributeDictionaries object

Version:

  • SketchUp 6.0

#each {|dict| ... } ⇒ Object

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

Throws an exception if there are no keys.

Examples:

model = Sketchup.active_model
attrdicts = model.attribute_dictionaries
# Iterates through all dictionaries and prints to screen.
attrdicts.each { | dict | UI.messagebox dict }

Yields:

  • (dict)

    Each AttributeDictionary as it is found.

Returns:

  • nil

Version:

  • SketchUp 6.0

#lengthInteger

The #length method returns the number of attribute dictionary objects in the collection.

Examples:

model = Sketchup.active_model
model.set_attribute('Example', 'Hello', 'World')
dictionaries = model.attribute_dictionaries
number = dictionaries.length

Returns:

  • (Integer)

    the number of attribute dictionary objects in the collection.

See Also:

Version:

  • SketchUp 2014

#sizeInteger

The #size method is an alias of #length.

Examples:

model = Sketchup.active_model
model.set_attribute('Example', 'Hello', 'World')
dictionaries = model.attribute_dictionaries
number = dictionaries.size

Returns:

  • (Integer)

See Also:

Version:

  • SketchUp 2014