Class: Layout::Entity

Inherits:
Object
  • Object
show all
Defined in:
SketchUp/Layout/Entity.rb

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.entities
# Count how many of the entites are a rectangle
rectangle_count = 0

# Look at all of the entities in the array.
entities.each { |entity|
  if entity.is_a?(Layout::Rectangle)
    rectangle_count = rectangle_count++
  end
}

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



40
41
# File 'SketchUp/Layout/Entity.rb', line 40

def ==(other)
end

#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



53
54
# File 'SketchUp/Layout/Entity.rb', line 53

def bounds
end

#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



68
69
# File 'SketchUp/Layout/Entity.rb', line 68

def document
end

#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



82
83
# File 'SketchUp/Layout/Entity.rb', line 82

def drawing_bounds
end

#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



97
98
# File 'SketchUp/Layout/Entity.rb', line 97

def group
end

#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



114
115
# File 'SketchUp/Layout/Entity.rb', line 114

def layer_instance
end

#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



128
129
# File 'SketchUp/Layout/Entity.rb', line 128

def locked=(is_locked)
end

#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)
  • (Boolean)

Version:

  • LayOut 2018



144
145
# File 'SketchUp/Layout/Entity.rb', line 144

def locked?
end

#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



175
176
# File 'SketchUp/Layout/Entity.rb', line 175

def move_to_group(group)
end

#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



215
216
# File 'SketchUp/Layout/Entity.rb', line 215

def move_to_layer(*args)
end

#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)
  • (Boolean)

Raises:

Version:

  • LayOut 2018



236
237
# File 'SketchUp/Layout/Entity.rb', line 236

def on_shared_layer?
end

#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



253
254
# File 'SketchUp/Layout/Entity.rb', line 253

def page
end

#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



268
269
# File 'SketchUp/Layout/Entity.rb', line 268

def style
end

#style=(style) ⇒ Object

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

Parameters:

Raises:

Version:

  • LayOut 2018



281
282
# File 'SketchUp/Layout/Entity.rb', line 281

def style=(style)
end

#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



301
302
# File 'SketchUp/Layout/Entity.rb', line 301

def transform!(transformation)
end

#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



314
315
# File 'SketchUp/Layout/Entity.rb', line 314

def transformation
end

#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



332
333
# File 'SketchUp/Layout/Entity.rb', line 332

def untransformed_bounds
end

#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



360
361
# File 'SketchUp/Layout/Entity.rb', line 360

def untransformed_bounds=(bounds)
end