123456789_123456789_123456789_123456789_123456789_

Class: Layout::LayerInstance

Relationships
Inherits: Object

Overview

References an instance of a Layer. A LayerInstance provides access to the Entitys that are on it, as well as their draw order. Groups are not included in the list of Entitys associated with a LayerInstance, since the group hierarchy has no effect on entity draw order. Each Page has one LayerInstance for each Layer in the Document. Non-shared LayerInstances are unique per Page, while shared LayerInstances are shared across all Pages of the Document.

Examples:

doc = Layout::Document.open("C:/path/to/document.layout")
layers = doc.layers
pages = doc.pages
layers.each do |layer|
  layer_instance = layer.layer_instance(pages.first)
  entities = layer_instance.entities
  entities.each do |entity|
    new_index = rand(entities.length - 1)
    layer_instance.reorder_entity(entity, new_index)
  end
end

Version:

  • LayOut 2018

Instance Method Summary

Instance Method Details

#==(other) ⇒ Boolean

The #== method checks to see if the two LayerInstances are equal. This checks whether the Ruby Objects are pointing to the same internal object.

Examples:

doc = Layout::Document.open("C:/path/to/document.layout")
document = doc.pages.first.document
doc.page.layer_instances.first == document.page.layer_instances.first

Parameters:

  • other (LayerInstance)

Version:

  • LayOut 2018

#definitionLayout::Layer

The #definition method returns the Layer of the LayerInstance.

Examples:

layer_def = layer_instance.definition

Version:

  • LayOut 2018

#entitiesLayout::Entities

The #entities method returns the Entities on the LayerInstance.

Examples:

doc = Layout::Document.open("C:/path/to/document.layout")
layers = doc.layers
pages = doc.pages
first_layer = layers.first
entities = first_layer.layer_instance.entities

Version:

  • LayOut 2018

#entity_index(entity) ⇒ Integer

The #entity_index method returns the index of the Entity on the LayerInstance.

Examples:

doc = Layout::Document.open("C:/path/to/document.layout")
layers = doc.layers
pages = doc.pages
instance = layers.first.layer_instance
instance.entities.each_with_index { |entity, index|
  puts "#{index} == #{instance.entity_index(entity)}"
}

Parameters:

Raises:

  • (ArgumentError)

    if entity is not on the LayerInstance

Version:

  • LayOut 2018

#reorder_entity(entity, index)

The #reorder_entity method moves the Entity to the specified index.

Examples:

doc = Layout::Document.open("C:/path/to/document.layout")
layers = doc.layers
pages = doc.pages
first_layer = layers.first
first_layer.set_shared(pages.first, SHARELAYERACTION_KEEPONEPAGE);
layer_instance = first_layer.layer_instance
entities = layer_instance.entities
# put the first entity into the back of the layer
layer_instance.reorder_entity(entities.first, (entities.length - 1))

Parameters:

Raises:

  • (ArgumentError)

    if entity is not on the LayerInstance

  • (IndexError)

    if index is out of range

Version:

  • LayOut 2018