Class: Layout::Entity

Inherits:
Object
  • Object
show all

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

Instance Method Details

#==(other) ⇒ Boolean

The #== method checks to see if the two Layout::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:

Returns:

  • (Boolean)

Version:

  • LayOut 2018

#boundsGeom::Bounds2d

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

Examples:

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

Returns:

Version:

  • LayOut 2018

#documentLayout::Document?

The #document method returns the Document that the Layout::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

Returns:

Version:

  • LayOut 2018

#drawing_boundsGeom::OrientedBounds2d

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

Examples:

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

Returns:

Version:

  • LayOut 2018

#groupLayout::Group?

The #group method returns the Group the Layout::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

Returns:

Version:

  • LayOut 2018

#layer_instanceLayout::LayerInstance?

Note:

Groups are never associated with a LayerInstance.

The #layer_instance method returns the LayerInstance that the Layout::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

Returns:

Version:

  • LayOut 2018

#locked=(is_locked) ⇒ Object

The #locked= method sets the Layout::Entity as locked or unlocked. When locked, the Layout::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

The #locked? method returns whether the Layout::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?

Returns:

  • (Boolean)

Version:

  • LayOut 2018

#move_to_group(group) ⇒ Object

The #move_to_group method moves the Layout::Entity into a Group. If the Layout::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 Layout::Entity, the old Group will be collapsed and the remaining Layout::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:

Version:

  • LayOut 2018

#move_to_layer(layer) ⇒ Object #move_to_layer(layer, pages) ⇒ Object

The #move_to_layer method moves the Layout::Entity to the given Layer. If the Layer is non-shared and the Layout::Entity is currently on a shared Layer, an array of Pages must be provided to move the Layout::Entity to. In all other cases, passing in an array of Pages is not necessary. The Layout::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

Known Bugs:

  • In LayOut versions prior to LayOut 2024.0 this method would fail to move entities from non-shared layers.

#on_shared_layer?Boolean

The #on_shared_layer? method returns whether or not the Layout::Entity is on a shared Layer. This function works for all Layout::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?

Returns:

  • (Boolean)

Raises:

Version:

  • LayOut 2018

#pageLayout::Page?

The #page method returns the Page that the Layout::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

Returns:

Version:

  • LayOut 2018

#styleLayout::Style?

The #style method returns the Style of the Layout::Entity. If the Layout::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

Returns:

Version:

  • LayOut 2018

#style=(style) ⇒ Object

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

Parameters:

Raises:

Version:

  • LayOut 2018

#transform!(transformation) ⇒ Object

The #transform! method transforms the Layout::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

Returns:

Version:

  • LayOut 2018

#untransformed_boundsGeom::Bounds2d

The #untransformed_bounds method returns the untransformed bounds of the Layout::Entity. This is the bounds of the Layout::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

Returns:

Raises:

Version:

  • LayOut 2018

#untransformed_bounds=(bounds) ⇒ Object

The #untransformed_bounds= method sets the untransformed bounds of the Layout::Entity. This is the bounds of the Layout::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