Class: Layout::Entities

Inherits:
Object
  • Object
show all
Includes:
Enumerable

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 # collapse

Instance Method Details

#[](index) ⇒ Layout::Entity

The #[] method returns the Layout::Entity at the given index. This method is not valid for use when the Layout::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)

Returns:

Raises:

  • (ArgumentError)

    if this came from a Page

Version:

  • LayOut 2018

#each(flags = {}) {|entity| ... } ⇒ 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::Entitys. When iterating over a LayerInstance's Layout::Entities, it is not necessary to provide a flags Hash. When iterating over a Page's Layout::Entities, the flags Hash is optional; providing no Hash will result in iterating over all Layout::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 Layout::Entitys on hidden or locked Layers

Yield Parameters:

Version:

  • LayOut 2018

#lengthInteger Also known as: size

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

Examples:

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

Returns:

  • (Integer)

Version:

  • LayOut 2018

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

The #reverse_each method iterates through all of the Layout::Entitys in reverse order. When iterating over a LayerInstance's Layout::Entities, it is not necessary to provide a flags Hash. When iterating over a Page's Layout::Entities, the flags Hash is optional; providing no Hash will result in iterating over all Layout::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| ... } ⇒ Object

    Yield Parameters:

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

    Parameters:

    • flags (Hash{Symbol => Boolean})

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

    Yield Parameters:

Version:

  • LayOut 2018