Class: Layout::Layers

Inherits:
Object
  • Object
show all
Includes:
Enumerable

Overview

The Layers class is a container class for all layers in a Document.

Examples:

# Grab a handle to the currently active document's layers
doc = Layout::Document.open("C:/path/to/document.layout")
layers = doc.layers

# From here, we can add layers to or remove them from the document
layers.add("New Layer")
layers.remove(layers[0])

Version:

  • LayOut 2018

Instance Method Summary # collapse

Instance Method Details

#[](index) ⇒ Layout::Layer

The #[] method returns a value from the array of Layout::Layers.

Examples:

doc = Layout::Document.open("C:/path/to/document.layout")
layers = doc.layers
layer = layers[2]

Parameters:

Returns:

Raises:

  • (IndexError)

    if index is out of range

Version:

  • LayOut 2018

#activeLayout::Layer

The #active method returns the active Layout::Layer in the Document.

Examples:

doc = Layout::Document.open("C:/path/to/document.layout")
layer = doc.layers.active

Returns:

Version:

  • LayOut 2018

#active=(layer) ⇒ Layout::Layer #active=(index) ⇒ Layout::Layer

The #active= method sets the active Layout::Layer that will be displayed the next time the Document is opened. This value will change whenever the Layout::Layer is changed in the Document in LayOut.

Examples:

doc = Layout::Document.open("C:/path/to/document.layout")
layers = doc.layers
layers.active = layers[0]

Overloads:

Version:

  • LayOut 2018

#add(shared = false) ⇒ Layout::Layer #add(name, shared = false) ⇒ Layout::Layer

The #add method adds a new Layout::Layer to the Document. The newly added Layout::Layer will be the last one in the Document.

Examples:

doc = Layout::Document.open("C:/path/to/document.layout")
new_layer = doc.layers.add

Overloads:

Version:

  • LayOut 2018

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

Note:

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 iterates through all of the Layout::Layers.

Examples:

doc = Layout::Document.open("C:/path/to/document.layout")
layers = doc.layers
layers.each { |layer|
  puts layer.name
}

Yield Parameters:

Version:

  • LayOut 2018

#index(layer) ⇒ Integer?

The #index method returns the index of the Layout::Layer, or nil if it doesn't exist in the Document.

Examples:

doc = Layout::Document.open("C:/path/to/document.layout")
layers = doc.layers
layer_index = layers.index(layers.first) # Returns 0

Parameters:

Returns:

  • (Integer, nil)

Version:

  • LayOut 2018

#lengthInteger Also known as: size

The #length method returns the number of Layout::Layers.

Examples:

doc = Layout::Document.open("C:/path/to/document.layout")
layers = doc.layers
num_layers = layers.length

Returns:

  • (Integer)

Version:

  • LayOut 2018

#remove(layer, delete_entities = false) ⇒ Object #remove(index, delete_entities = false) ⇒ Object

The #remove method deletes the given Layout::Layer from the Document.

Examples:

doc = Layout::Document.open("C:/path/to/document.layout")
layers = doc.layers
layers.remove(layers[0])

Overloads:

  • #remove(layer, delete_entities = false) ⇒ Object

    Parameters:

    Raises:

  • #remove(index, delete_entities = false) ⇒ Object

    Parameters:

    • index (Integer)

      The index of the Layout::Layer to be removed

    • delete_entities (Boolean) (defaults to: false)

      Whether the Entitys on the deleted Layout::Layer should be deleted as well

    Raises:

    • (IndexError)

      if index is out of range

    • (ArgumentError)

      if the Layout::Layer is the only one in the Document

Version:

  • LayOut 2018

#reorder(layer, new_index) ⇒ Object #reorder(index, new_index) ⇒ Object

The #reorder method moves a Layout::Layer to a different index within the Document's list of layers. This will move the Layout::Layer such that its new index becomes new_index.

Examples:

doc = Layout::Document.open("C:/path/to/document.layout")
layers = doc.layers
layers.reorder(layers[1], 3)

Overloads:

  • #reorder(layer, new_index) ⇒ Object

    Parameters:

    Raises:

    • (ArgumentError)

      if the Layout::Layer is not in the Document

    • (IndexError)

      if new_index is out of range

  • #reorder(index, new_index) ⇒ Object

    Parameters:

    • index (Integer)

      The index of the Layout::Layer to be reordered

    • new_index (Integer)

      The index to put the Layout::Layer at

    Raises:

    • (IndexError)

      if index or new_index are out of range

Version:

  • LayOut 2018