Class: Sketchup::AttributeDictionaries

Inherits:
Entity show all
Includes:
Enumerable
Defined in:
lib/attributedictionaries.rb

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.

By default, when entity is created it has no AttributeDictionaries object: g = Sketchup.active_model.entities.add_group g.attribute_dictionaries # => nil The AttributeDictionaries object is added to the entity only once the first attribute is added to the entity: g.set_attribute("Test", "Yo", "Hello") g.attribute_dictionaries # => #Sketchup::Group:0x00000007569bc0> When iterating through entity attribute dictionaries, be sure to verify that Sketchup::Entity.#attribute_dictionaries is not nil.

Examples:

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

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

See Also:

Since:

  • SketchUp 6.0

Instance Method Summary collapse

Methods inherited from Entity

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

Instance Method Details

#[](key) ⇒ AttributeDictionary

Get an Sketchup::AttributeDictionary object by name.

Examples:

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

Parameters:

  • key (String)

    The name of the attribute dictionary.

Returns:

  • (AttributeDictionary)

    An attribute dictionary if it exits or +nil+ if none with the specified key exist.

Since:

  • SketchUp 6.0



55
56
# File 'lib/attributedictionaries.rb', line 55

def [](key)
end

#delete(key_or_dict) ⇒ AttributeDictionaries

Examples:

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

Parameters:

Returns:

Since:

  • SketchUp 6.0



70
71
# File 'lib/attributedictionaries.rb', line 70

def delete(key_or_dict)
end

#each {|dictionary| ... } ⇒ nil

Iterate through all of the attribute dictionaries.

Examples:

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

Yield Parameters:

Returns:

  • (nil)

Since:

  • SketchUp 6.0



85
86
# File 'lib/attributedictionaries.rb', line 85

def each
end

#lengthFixnum Also known as: size

Get the number of Sketchup::AttributeDictionary objects in the collection.

Examples:

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

Returns:

  • (Fixnum)

Since:

  • SketchUp 2014



99
100
# File 'lib/attributedictionaries.rb', line 99

def length
end