123456789_123456789_123456789_123456789_123456789_

Class: Layout::Entity

Relationships
Extension / Inclusion / Inheritance Descendants
Subclasses:
Inherits: Object

Overview

An entity is an object shown on a page of a LayOut document.

Examples:

doc = Layout::Document.open("C:/path/to/document.layout")
# Get the shared entities in the document. If there are no shared layers,
# the resulting array will be empty.
entities = doc.shared_entities

# Count how many of the shared entites are rectangles.
rectangle_count = entities.grep(Layout::Rectangle).size

Version:

  • LayOut 2018

Instance Attribute Summary

Instance Method Summary

Instance Attribute Details

#locked=(is_locked) (rw)

The #locked= method sets the Entity as locked or unlocked. When locked, the Entity cannot be modified directly.

Examples:

doc = Layout::Document.open("C:/path/to/document.layout")
entities = doc.pages.first.entities
entities.first.locked = true

Parameters:

  • is_locked (Boolean)

Version:

  • LayOut 2018

#locked?Boolean (rw)

The #locked? method returns whether the Entity is locked or unlocked.

Examples:

doc = Layout::Document.open("C:/path/to/document.layout")
entities = doc.pages.first.entities
is_first_locked = entities.first.locked?

Version:

  • LayOut 2018

#on_shared_layer?Boolean (readonly)

The #on_shared_layer? method returns whether or not the Entity is on a shared Layer. This function works for all Entity types, including Group. Groups do not belong to a specific Layer, but their children are all on either a shared or non-shared Layer.

Examples:

doc = Layout::Document.open("C:/path/to/document.layout")
entities = doc.pages.first.entities
on_shared_layer = entities.first.on_shared_layer?

Raises:

  • (ArgumentError)

    if the Entity is not in a Document

Version:

  • LayOut 2018

#styleLayout::Style? (rw)

The #style method returns the Style of the Entity. If the Entity is a Group, nil will be returned, as they do not have a Style.

Examples:

doc = Layout::Document.open("C:/path/to/document.layout")
entities = doc.entities
style = entities.first.style

Version:

  • LayOut 2018

#style=(style) (rw)

The #style= method sets the Style of the Entity.

Parameters:

Raises:

Version:

  • LayOut 2018

#untransformed_boundsGeom::Bounds2d (rw)

The #untransformed_bounds method returns the untransformed bounds of the Entity. This is the bounds of the Entity before its explicit ::Geom::Transformation2d is applied.

Examples:

doc = Layout::Document.open("C:/path/to/document.layout")
entities = doc.pages.first.entities
bounds = entities.first.untransformed_bounds

Raises:

Version:

  • LayOut 2018

#untransformed_bounds=(bounds) (rw)

The #untransformed_bounds= method sets the untransformed bounds of the Entity. This is the bounds of the Entity before its explicit ::Geom::Transformation2d is applied.

Examples:

doc = Layout::Document.open("C:/path/to/document.layout")
entities = doc.pages.first.entities
point1 = Geom::Point2d.new(1, 1)
point2 = Geom::Point2d.new(2, 2)
bounds = Geom::Bounds2d(point1, point2)
entities.first.untransformed_bounds = bounds

Parameters:

Raises:

Version:

  • LayOut 2018

Instance Method Details

#==(other) ⇒ Boolean

The #== method checks to see if the two Entitys 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")
page_entities = doc.pages.first.entities
layer_entities = doc.layers.first.layer_instance(page).entities
page_entities.first == layer_entities.first

Parameters:

  • other (Entity)

Version:

  • LayOut 2018

#boundsGeom::Bounds2d

The #bounds method returns the 2D rectangular bounds of the Entity.

Examples:

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

Version:

  • LayOut 2018

#documentLayout::Document?

The #document method returns the Document that the Entity belongs to, or nil if it is not in a Document.

Examples:

doc = Layout::Document.open("C:/path/to/document.layout")
entities = doc.shared_entities
# entity_doc should be the same document as doc
entity_doc = entities.first.document

Version:

  • LayOut 2018

#drawing_boundsGeom::OrientedBounds2d

The #drawing_bounds method returns the 2D rectangular drawing bounds of the Entity.

Examples:

doc = Layout::Document.open("C:/path/to/document.layout")
entities = doc.pages.first.entities
draw_bounds = entities.first.drawing_bounds

Version:

  • LayOut 2018

#groupLayout::Group?

The #group method returns the Group the Entity belongs to, or nil if it is not in a Group.

Examples:

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

Version:

  • LayOut 2018

#layer_instanceLayout::LayerInstance?

Note:

Groups are never associated with a LayerInstance.

The #layer_instance method returns the LayerInstance that the Entity is on, or nil if it is not associated with a LayerInstance.

Examples:

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

Version:

  • LayOut 2018

#move_to_group(group)

The #move_to_group method moves the Entity into a Group. If the Entity is already in a Group, it will be removed from that Group prior to being added to the new one. If this action results in the old Group containing only one Entity, the old Group will be collapsed and the remaining Entity will be moved to the old Group‘s parent.

Examples:

doc = Layout::Document.open("C:/path/to/document.layout")
entities = doc.pages.first.entities
new_group = Layout::Group.new
entities.first.move_to_group(new_group)

Parameters:

Raises:

  • (LockedLayerError)

    if the Entity is on a locked Layer

  • (ArgumentError)

    if entity and group are not in the same Document

  • (ArgumentError)

    if entity and group are not on the same Page

  • (ArgumentError)

    if of entity and group one is shared and one is not

  • (LockedEntityError)

    if the Entity is locked

Version:

  • LayOut 2018

#move_to_layer(layer) #move_to_layer(layer, pages)

The #move_to_layer method moves the Entity to the given Layer. If the Layer is non-shared and the Entity is currently on a shared Layer, an array of Pages must be provided to move the Entity to. In all other cases, passing in an array of Pages is not necessary. The Entity must belong to the same Document as the the Layer and the Pages.

Examples:

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

Overloads:

Raises:

Version:

  • LayOut 2018

#pageLayout::Page?

The #page method returns the Page that the Entity belongs to, or nil if it is on a shared Layer or not in a Document.

Examples:

doc = Layout::Document.open("C:/path/to/document.layout")
# page will be nil
page = doc.shared_entities.first.page
# page will be the first page of the document
page = doc.pages.first.nonshared_entities.first.page

Version:

  • LayOut 2018

#transform!(transformation)

The #transform! method transforms the Entity with a given ::Geom::Transformation2d.

Examples:

doc = Layout::Document.open("C:/path/to/document.layout")
entities = doc.pages.first.entities
transform = Geom::Transformation2d.new([1.0, 0.0, 0.0, 1.0, 1.0, 1.0])
entity = entities.first.transform!(transform)

Parameters:

Raises:

Version:

  • LayOut 2018

#transformationGeom::Transformation2d?

The #transformation method returns the explicit ::Geom::Transformation2d.

Examples:

doc = Layout::Document.open("C:/path/to/document.layout")
entities = doc.pages.first.entities
transform = entities.first.transformation

Version:

  • LayOut 2018