Class: Sketchup::Layers
Overview
As of SketchUp 2020 “Layers” were renamed to “Tags” in the UI. The API retains the use of “Layer” for compatibility and is synonymous with “Tag”.
The Layers collection allows you to see and manage all of the layers in a model. You get a pointer to the Layers object from within the Model.
Instance Method Summary # collapse
-
#[](index_or_name) ⇒ Sketchup::Layer?
The #[] method is used to retrieve a layer by index or name.
-
#add(layer_name) ⇒ Sketchup::Layer
(also: #add_layer)
The #add method is used to add a new layer.
-
#add_folder(arg) ⇒ Sketchup::LayerFolder
The #add_folder method adds or moves a layer folder.
-
#add_observer(observer) ⇒ Boolean
The #add_observer method is used to add an observer to the layers collection.
- #at(index_or_name) ⇒ Sketchup::Layer?
-
#count ⇒ Object
Integer - the number of layers in the collection.
-
#count_folders ⇒ Integer
The #count_folders method counts the number of folders which are direct children of the layer manager.
-
#count_layers ⇒ Integer
The #count_layers method retrieves the number of layers not in a folder.
-
#each {|layer| ... } ⇒ Object
The #each method is used to iterate through all of the layers in the model.
-
#each_folder {|folder| ... } ⇒ Object
The #each_folder method is used to iterate through the folders that are direct children to the layer manager.
-
#each_layer {|layer| ... } ⇒ Object
The #each_layer method is used to iterate through the layers that are not inside a layer folder.
-
#folders ⇒ Array<Sketchup::LayerFolder>
The #folders method returns the folders of the layer manager.
-
#layers ⇒ Array<Sketchup::Layer>
The #layers method retrieves the layers not in a folder.
-
#length ⇒ Integer
The #length method retrieves the number of layers.
-
#purge_unused ⇒ Integer
(also: #purge_unused_layers)
The #purge_unused method is used to remove unused layers.
-
#purge_unused_folders {|folder| ... } ⇒ Object
The #purge_unused_folders method is used to remove all layer folder with no children.
-
#remove(layer, remove_geometry = false) ⇒ Boolean
(also: #remove_layer)
Remove the given layer from the model, optionally removing the geometry.
-
#remove_folder(folder) ⇒ nil
The #remove_folder method removes the folder from the model.
-
#remove_observer(observer) ⇒ Boolean
The #remove_observer method is used to remove an observer from the current object.
- #size ⇒ Integer
-
#unique_name(*args) ⇒ Object
The #unique_name method can be used to get a string that will be a unique layer name inside this collection.
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_or_name) ⇒ Sketchup::Layer?
The #[] method is used to retrieve a layer by index or name.
↑ #add(layer_name) ⇒ Sketchup::Layer Also known as: add_layer
The #add method is used to add a new layer.
If you give the name of a Layer that is already defined, it will return the existing Layer rather than adding a new one.
↑ #add_folder(name) ⇒ Sketchup::LayerFolder #add_folder(folder) ⇒ Sketchup::LayerFolder
The #add_folder method adds or moves a layer folder.
↑ #add_observer(observer) ⇒ Boolean
The #add_observer method is used to add an observer to the layers collection.
↑ #at(index_or_name) ⇒ Sketchup::Layer?
↑ #count ⇒ Object
↑ #count_folders ⇒ Integer
The #count_folders method counts the number of folders which are direct children of the layer manager.
↑ #count_layers ⇒ Integer
The #count_layers method retrieves the number of layers not in a folder.
↑ #each {|layer| ... } ⇒ Object
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 layers in the model. This include layers that are nested inside folders.
↑ #each_folder {|folder| ... } ⇒ Object
The #each_folder method is used to iterate through the folders that are direct children to the layer manager.
↑ #each_layer {|layer| ... } ⇒ Object
The #each_layer method is used to iterate through the layers that are not inside a layer folder.
↑ #folders ⇒ Array<Sketchup::LayerFolder>
This does not return all the folders in the model, only those that are direct children of the layer manager.
The #folders method returns the folders of the layer manager.
↑ #layers ⇒ Array<Sketchup::Layer>
The #layers method retrieves the layers not in a folder.
↑ #purge_unused ⇒ Integer Also known as: purge_unused_layers
The #purge_unused method is used to remove unused layers.
↑ #purge_unused_folders {|folder| ... } ⇒ Object
The #purge_unused_folders method is used to remove all layer folder with no children.
↑ #remove(layer, remove_geometry = false) ⇒ Boolean Also known as: remove_layer
Remove the given layer from the model, optionally removing the geometry.
↑ #remove_folder(folder) ⇒ nil
The #remove_folder method removes the folder from the model. All children are preserved, but moved up one level.
↑ #remove_observer(observer) ⇒ Boolean
The #remove_observer method is used to remove an observer from the current object.
↑ #unique_name ⇒ String #unique_name(base_name) ⇒ String
The #unique_name method can be used to get a string that will be a unique layer name inside this collection.