Class: Sketchup::Materials
Overview
A collection of Materials objects. Each model contains a Materials collection that can be accessed via Model.materials.
Instance Method Summary # collapse
-
#[](arg) ⇒ Object
The #[] method is used to retrieve a material by index or name.
-
#add(name) ⇒ Sketchup::Material
Add a new Material.
-
#add_observer(observer) ⇒ Boolean
The add_observer method is used to add an observer to the materials collection.
-
#at(arg) ⇒ Object
The #[] method is used to retrieve a material by index or name.
- #count ⇒ Integer
-
#current ⇒ Sketchup::Material
The current method is used to get the current material, i.e.
-
#current=(material) ⇒ Sketchup::Material
The current= method is used to set the current material.
-
#each {|material| ... } ⇒ Sketchup::Materials
The #each method is used to iterate through all of the materials.
-
#length ⇒ Integer
The number of materials in the collection.
-
#load(filename) ⇒ Sketchup::Material
The #load method is used to load a material from file into the model.
-
#purge_unused ⇒ Sketchup::Materials
The purge_unused method is used to remove unused materials.
-
#remove(material) ⇒ Boolean
Remove a given material.
-
#remove_observer(observer) ⇒ Boolean
The remove_observer method is used to remove an observer from the materials collection.
-
#size ⇒ Integer
The number of materials in the collection.
-
#unique_name(name) ⇒ String
The #unique_name method is used to retrieve a unique name from the materials collection that is based on the provided one.
Methods inherited from Entity
#attribute_dictionaries, #attribute_dictionary, #delete_attribute, #deleted?, #entityID, #get_attribute, #inspect, #model, #parent, #persistent_id, #set_attribute, #to_s, #typename, #valid?
Instance Method Details
↑ #[](index) ⇒ Sketchup::Material? #[](name) ⇒ Sketchup::Material?
↑ #add(name) ⇒ Sketchup::Material
Add a new Material. When called with no arguments, this will generate a new unique name for the new Material. If a name is given, it will check to see if there is already a material with that name. If there is already a material with the given name, then a new unique name is generated using the given name as a base.
↑ #add_observer(observer) ⇒ Boolean
The add_observer method is used to add an observer to the materials collection.
↑ #[](index) ⇒ Sketchup::Material? #[](name) ⇒ Sketchup::Material?
↑ #count ⇒ Integer
↑ #current ⇒ Sketchup::Material
The current method is used to get the current material, i.e. the material that the user has selected in the Materials dialog.
↑ #current=(material) ⇒ Sketchup::Material
The current= method is used to set the current material.
↑ #each {|material| ... } ⇒ Sketchup::Materials
Don't remove content from this collection while iterating over it with #each. This would change the size of the collection and cause elements to be skipped as the indices change. Instead copy the current collection to an array using to_a
and then use each
on the array, when removing content.
The #each method is used to iterate through all of the materials.
↑ #length ⇒ Integer
↑ #load(filename) ⇒ Sketchup::Material
The #load method is used to load a material from file into the model.
If a matching material exist in the model it will be returned instead.
↑ #purge_unused ⇒ Sketchup::Materials
The purge_unused method is used to remove unused materials.
↑ #remove(material) ⇒ Boolean
Remove a given material.
↑ #remove_observer(observer) ⇒ Boolean
The remove_observer method is used to remove an observer from the materials collection.
↑ #size ⇒ Integer
↑ #unique_name(name) ⇒ String
The #unique_name method is used to retrieve a unique name from the materials collection that is based on the provided one. If provided name is unique it will be returned, otherwise any trailing indices will be replaced by a new index.