123456789_123456789_123456789_123456789_123456789_

Class: Sketchup::LayerFolder

Relationships
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, Entity
Instance Chain:
self, Comparable, Entity
Inherits: Sketchup::Entity

Overview

Note:

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”.

Allows layers to be organized in folders. Folders may have duplicate names.

Version:

  • SketchUp 2021.0

Instance Attribute Summary

Entity - Inherited

#deleted?

The deleted? method is used to determine if your entity is still valid (not deleted by another script, for example.).

#valid?

The #valid? method is used to determine if your entity is still valid (not deleted by another script, for example).

Instance Method Summary

Entity - Inherited

#add_observer

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

#attribute_dictionaries

The attribute_dictionaries method is used to retrieve the AttributeDictionaries collection attached to the entity.

#attribute_dictionary

The attribute_dictionary method is used to retrieve an attribute dictionary with a given name that is attached to an Entity.

#delete_attribute

The #delete_attribute method is used to delete an attribute from an entity.

#entityID

The entityID method is used to retrieve a unique ID assigned to an entity.

#get_attribute

The #get_attribute method is used to retrieve the value of an attribute in the entity’s attribute dictionary.

#inspect

The #inspect method is used to retrieve the string representation of the entity.

#model

The model method is used to retrieve the model for the entity.

#parent

The parent method is used to retrieve the parent of the entity.

#persistent_id

The #persistent_id method is used to retrieve a unique persistent id assigned to an entity.

#remove_observer

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

#set_attribute

The set attribute is used to set the value of an attribute in an attribute dictionary with the given name.

#to_s

The #to_s method is used to retrieve the string representation of the entity.

#typename

The typename method retrieves the type of the entity, which will be a string such as “Face”, “Edge”, or “Group”.

Instance Attribute Details

#folderLayerFolder? (rw)

The #folder method is used to return the parent layer folder of a layer folder.

Examples:

model = Sketchup.active_model
layers = model.layers
folder1 = layers.add_folder('Folder1')
parent_folder = folder1.folder # Returns: nil

folder2 = folder1.add_folder('Folder2')
parent_folder = folder2.folder # Returns: folder1

Returns:

  • (LayerFolder, nil)

    nil if the folder is a direct child to the layer manager.

Version:

  • SketchUp 2021.0

#folder=(parent) (rw)

The #folder= method is used to set the parent layer folder of a layer folder.

This will trigger onLayerFolderRemoved followed by onLayerFolderAdded.

Examples:

model = Sketchup.active_model
layers = model.layers
folder1 = layers.add_folder('Folder1')
folder2 = layers.add_folder('Folder2')

folder2.folder = folder1

Parameters:

  • parent (LayerFolder, nil)

    nil will make the the folder a direct child to the layer manager.

Version:

  • SketchUp 2021.0

#nameString (rw) Also known as: #display_name

The #name method gets the name of the folder.

Examples:

manager = Sketchup.active_model.layers
folder = manager.add_folder('Doors')
name = folder.name

Version:

  • SketchUp 2021.0

#name=(name) (rw)

The #name= method sets the name of the folder.

Examples:

manager = Sketchup.active_model.layers
folder = manager.add_folder('Doors')
folder.name = 'Windows'

Parameters:

Raises:

  • (ArgumentError)

    if name is empty.

Version:

  • SketchUp 2021.0

#visible=(visible) (rw)

The #visible= method is used to set if the layer folder is visible.

Examples:

model = Sketchup.active_model
layers = model.layers
folder = layers.add('Hello')
folder.visible = false

Parameters:

  • visible (Boolean)

Version:

  • SketchUp 2021.0

#visible?Boolean (rw)

The #visible? method is used to determine if the layer folder is visible.

Examples:

model = Sketchup.active_model
layers = model.layers
folder = layers.add('Hello')
folder.visible? # Returns: true

Version:

  • SketchUp 2021.0

#visible_on_new_pages=(visible) (rw)

The #visible_on_new_pages= method is used to set if the layer folder is by default visible on new pages.

Examples:

model = Sketchup.active_model
layers = model.layers
folder = layers.add_folder('Hello')
folder.visible_on_new_pages = false
page = model.pages.add('My Page')
model.pages.select_page = page # `folder` will now be hidden.

Parameters:

  • visible (Boolean)

Version:

  • SketchUp 2021.0

#visible_on_new_pages?Boolean (rw)

The #visible_on_new_pages? method is used to determine if the layer folder is by default visible on new pages.

Examples:

model = Sketchup.active_model
layers = model.layers
folder = layers.add_folder('Hello')
folder.visible_on_new_pages? # Returns: true

Version:

  • SketchUp 2021.0

Instance Method Details

#<=>(other) ⇒ Integer?

The #<=> method is used to compare two layer folders based on their names. This enables the Ruby Array#sort method to sort SketchUp layer folders.

Examples:

model = Sketchup.active_model
layers = model.layers
folder1 = layers.add_folder('Folder1')
folder2 = layers.add_folder('Folder2')
comparison = folder1 <=> folder2 # Returns: -1
comparison = folder1 <=> folder1 # Returns: 0
comparison = folder2 <=> folder1 # Returns: 1

Parameters:

  • other (Object)

Returns:

  • (Integer, nil)

    -1 if the receiver should appear before other. 1 if the receiver should appear after other. 0 if the receiver and other are equal. nil if other is not comparable with the receiver.

Version:

  • SketchUp 2021.0

#==(other) ⇒ Boolean

The #== method is used to determine if two layer folders are the same.

Examples:

model = Sketchup.active_model
layers = model.layers
folder1 = layers.add('Folder1')
folder2 = layers.add('Folder2')
equal = folder1 == folder2

Parameters:

  • other (Object)

Version:

  • SketchUp 2021.0

#add_folder(name) ⇒ LayerFolder #add_folder(folder) ⇒ LayerFolder

The #add_folder method adds or moves a layer folder.

Examples:

manager = Sketchup.active_model.layers
folder1 = manager.add_folder('Doors')
folder2 = folder1.add_folder('Outer Doors')

Overloads:

See Also:

Version:

  • SketchUp 2021.0

#add_layer(layer) ⇒ nil

The #add_layer method adds a layer to a folder.

Examples:

manager = Sketchup.active_model.layers
layer = manager.add_layer('Inner Doors')
folder = manager.add_folder('Doors')

folder.add_layer(layer)

Parameters:

See Also:

Version:

  • SketchUp 2021.0

#count_foldersInteger

The #count_folders method retrieves the number of child folders in the folder.

Examples:

layers = Sketchup.active_model.layers
folder1 = layers.add_folder('Hello')
folder2 = folder1.add_folder('World')
number = folder1.folder_count # Returns: 1

Version:

  • SketchUp 2021.0

#count_layersInteger Also known as: #length, #size

The #count_layers method retrieves the number of layers in the folder.

Examples:

layers = Sketchup.active_model.layers
layer = layers.add_layer('World')
folder = layers.add_folder('Hello')
folder.add_layer(layer)
number = folder.layer_count # Returns: 1

See Also:

Version:

  • SketchUp 2021.0

#display_name

Alias for #name.

#each

Alias for #each_layer.

#each_folder {|folder| ... }

The #each_folder method is used to iterate through the folders that are direct children to the folder.

Examples:

model = Sketchup.active_model
layers = model.layers
folder1 = layers.add_folder('Hello')
folder1.add_folder('World')
folder1.each_folder { | folder | puts folder.name }

Yields:

Yield Parameters:

  • folder (LayerFolder)

Version:

  • SketchUp 2021.0

#each_layer {|layer| ... } Also known as: #each

The #each_layer method is used to iterate through the layers that are direct children to the folder.

Examples:

model = Sketchup.active_model
layers = model.layers
layer = layers.add_layer('World')
folder = layers.add_folder('Hello')
folder.add_layer(layer)
folder.each_layer { | layer | puts layer.name }

Yields:

  • (layer)

Yield Parameters:

Version:

  • SketchUp 2021.0

#foldersArray<LayerFolder>

The #folders returns the direct child-folders of the folder.

Examples:

manager = Sketchup.active_model.layers
folder1 = manager.add_folder('Doors')
folder2 = folder1.add_folder('Windows')
folders = folder1.folders

Version:

  • SketchUp 2021.0

#layersArray<Sketchup::Layer>

The #layers method retrieves the child layers of a folder.

Examples:

manager = Sketchup.active_model.layers
folder = manager.add_folder('Hello')
folder.add_layer(manager.add_layer('World'))
folder.add_layer(manager.add_layer('Universe'))

layers = folder.layers

Version:

  • SketchUp 2021.0

#length

Alias for #count_layers.

#remove_folder(folder) ⇒ nil

The #remove_folder method removes the folder from the model. All children are preserved, but move up one level.

Examples:

manager = Sketchup.active_model.layers
folder1 = manager.add_folder('Doors')
folder2 = manager.add_folder('Outer Doors')
folder1.remove_folder(folder2)

Parameters:

  • folder (LayerFolder)

Raises:

  • (ArgumentError)

    if the folder is not a direct child of the receiver.

Version:

  • SketchUp 2021.0

#remove_layer(layer) ⇒ nil

The #remove_layer method removes a layer from a folder. The layer will be parent to the layer manager.

Examples:

manager = Sketchup.active_model.layers
layer = manager.add_layer('Inner Doors')
folder = manager.add_folder('Doors')
folder.add_layer(layer)

folder.remove_layer(layer)

Parameters:

Version:

  • SketchUp 2021.0

#size

Alias for #count_layers.