123456789_123456789_123456789_123456789_123456789_

Class: Layout::Entities

Relationships
Super Chains via Extension / Inclusion / Inheritance
Instance Chain:
self, Enumerable
Inherits: Object

Overview

The Entities class is a container class for Entitys. A Entities object is different from a SketchUp::Entities object in that it is read-only. Adding or removing Entitys from a Document happens with the Document#add_entity and Document#remove_entity methods.

The Entities from AngularDimension#entities, Label#entities, LinearDimension#entities, or Table#entities contains the Entitys that represent the Entity in its exploded form.

The Entities from Group#entities contains all the Entitys that belong to the Group.

The Entities from Page#entities contains all of the Entitys on both shared and non-shared Layers. This class is used to iterate through the Entitys in draw order or pick order (reverse draw order) using the #each and #reverse_each methods.

The Entities from Document#shared_entities contains all of the Entitys that belong on all shared Layers.

The Entities from Page#nonshared_entities contains all of the Entitys that belong to that Page.

The Entities from LayerInstance#entities contains all of the Entitys that belong on that LayerInstance.

Examples:

# Grab a handle to a pages entities
doc = Layout::Document.open("C:/path/to/document.layout")
entities = doc.pages.first.entities

# From here, we can iterate over the entities in draw order or pick order
entities.each { |entity|
  puts entity
}
entities.reverse_each(skip_locked: true) { |entity|
  puts entity
}

Version:

  • LayOut 2018

Instance Method Summary

Instance Method Details

#[](index) ⇒ Layout::Entity

The #[] method returns the Entity at the given index. This method is not valid for use when the Entities object came from a Page.

Examples:

table = Layout::Table.new([1, 1, 4, 4], 4, 4)
entities = table.entities
entity = entities[10]

Parameters:

  • index (Integer)

Raises:

  • (ArgumentError)

    if this came from a Page

Version:

  • LayOut 2018

#each(flags = {}) {|entity| ... }

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 Entitys. When iterating over a LayerInstance‘s Entities, it is not necessary to provide a flags Hash. When iterating over a Page’s Entities, the flags Hash is optional; providing no Hash will result in iterating over all Entitys, including those on hidden or locked Layers. Valid symbols for the Hash are :skip_hidden and :skip_locked.

Examples:

doc = Layout::Document.open("C:/path/to/document.layout")
flags = { :skip_hidden => true }
entities = doc.pages.first.entities
entities.each(flags) { |entity|
  puts entity
}

Parameters:

  • flags (Hash{Symbol => Boolean}) (defaults to: {})

    A hash that allows skipping of Entitys on hidden or locked Layers

Yield Parameters:

Version:

  • LayOut 2018

#lengthInteger Also known as: #size

The #length method returns the number of Entitys.

Examples:

doc = Layout::Document.open("C:/path/to/document.layout")
entities = doc.shared_entities
num_entities = entities.length

Version:

  • LayOut 2018

#reverse_each {|entity| ... } #reverse_each(flags) {|entity| ... }

The #reverse_each method iterates through all of the Entitys in reverse order. When iterating over a LayerInstance‘s Entities, it is not necessary to provide a flags Hash. When iterating over a Page’s Entities, the flags Hash is optional; providing no Hash will result in iterating over all Entitys, including those on hidden or locked Layers. Valid symbols for the Hash are :skip_hidden and :skip_locked.

Examples:

doc = Layout::Document.open("C:/path/to/document.layout")
flags = { :skip_hidden => true, :skip_locked => true }
entities = doc.pages.first.entities
entities.reverse_each(flags) { |entity|
  puts entity
}

Overloads:

  • #reverse_each {|entity| ... }

    Yield Parameters:

  • #reverse_each(flags) {|entity| ... }

    Parameters:

    • flags (Hash{Symbol => Boolean})

      A hash that allows skipping of Entitys on hidden or locked Layers.

    Yield Parameters:

Version:

  • LayOut 2018

#size

Alias for #length.