Class: Sketchup::Entities

Inherits:
Object
  • Object
show all
Includes:
Enumerable

Overview

The Entities class is a container class for all entities in a model (it is a collection of Entity objects).

Version:

  • SketchUp 6.0

Instance Method Summary # collapse

Instance Method Details

#[](entity_index) ⇒ Sketchup::Entity?

The #[] method is used to retrieve an entity by its index in an array of entities. The index is a number between 0 and entities.length - 1. In general, it is preferable to use the #each method to iterate though all of the entities in the collection as it will be much more efficient.

Examples:

entities = Sketchup.active_model.entities
entity = entities[0]

Parameters:

  • entity_index (Integer)

    The index for a specific entity.

Returns:

See Also:

Version:

  • SketchUp 6.0

#active_section_planeObject

The active_section_plane method is used to access the currently active section plane in the Entities object.

Examples:

sp = Sketchup.active_model.entities.active_section_plane
puts "Active section plane is #{sp}" if !sp.nil?

Returns:

  • the active SectionPlane or nil if none is active.

Version:

  • SketchUp 2014

#active_section_plane(sec_plane) ⇒ Object

The active_section_plane= method is used to set the active section plane in the Entities object.

Examples:

entities = Sketchup.active_model.entities
sp = entities.add_section_plane([50, 50, 0], [1.0, 1.0, 0])
entities.active_section_plane = sp

Returns the SectionPlane object that was set active.

Parameters:

  • sec_plane

    the SectionPlane object to be set active. Pass nil to deactivate any active section plane.

Returns:

  • the SectionPlane object that was set active.

Version:

  • SketchUp 2014

#add_3d_text(string, alignment, font, is_bold, is_italic, letter_height, tolerance, z, is_filled, extrusion) ⇒ Object

The add_3d_text is used to create 3D text. It will be added as edges and faces drawn at the origin.

Examples:

# Draw the word "test" at the origin of the model, aligned left, in
# Arial Bold, not italics, 1" in size, best tolerance quality, filled,
# with an extrusion size of 5".
entities = Sketchup.active_model.entities
success = entities.add_3d_text('test', TextAlignLeft, "Arial",
  true, false, 1.0, 0.0, 0.5, true, 5.0)

Returns true if successful

Parameters:

  • string

    The text to create.

  • alignment

    Number that defines the alignment. There are constants called TextAlignLeft, TextAlignRight, and TextAlignCenter that can be passed.

  • font

    String font name.

  • is_bold (optional)

    Boolean, true for bold.

  • is_italic (optional)

    Boolean, true for italic.

  • letter_height (optional)

    Height of the text in inches.

  • tolerance (optional)

    Tolerance of the curve creation. Defaults to 0.0, which creates the highest possible curve quality.

  • z (optional)

    z position in inches.

  • is_filled (optional)

    Boolean, true for filled, which will put a face between the edges of the letters.

  • extrusion (optional)

    Extrusion depth in inches. Defaults to 0.0.

Returns:

  • true if successful

Version:

  • SketchUp 6.0

#add_arc(center, xaxis, normal, radius, start_angle, end_angle) ⇒ Object #add_arc(center, xaxis, normal, radius, start_angle, end_angle, num_segments) ⇒ Object

The add_arc method is used to create an arc curve segment.

Examples:

centerpoint = Geom::Point3d.new
# Create a circle perpendicular to the normal or Z axis
vector = Geom::Vector3d.new 0,0,1
vector2 = Geom::Vector3d.new 1,0,0
vector3 = vector.normalize!
model = Sketchup.active_model
entities = model.active_entities
edges = entities.add_arc centerpoint, vector2, vector3, 10, 15.degrees, 135.degrees
arccurve = edges.first.curve

Overloads:

  • #add_arc(center, xaxis, normal, radius, start_angle, end_angle) ⇒ Object

    Returns edges - an array of Edge objects that define the arc.

    Parameters:

    • center

      A Point3d object representing the center .

    • xaxis

      A Vector3d object representing xaxis for the arc.

    • normal

      A Vector3d object representing normal for the arc.

    • radius

      The radius of the arc.

    • start_angle

      Start angle for the arc, in radians.

    • end_angle

      End angle for the arc, in radians.

    Returns:

    • edges - an array of Edge objects that define the arc.

  • #add_arc(center, xaxis, normal, radius, start_angle, end_angle, num_segments) ⇒ Object

    Returns edges - an array of Edge objects that define the arc.

    Parameters:

    • center

      A Point3d object representing the center .

    • xaxis

      A Vector3d object representing xaxis for the arc.

    • normal

      A Vector3d object representing normal for the arc.

    • radius

      The radius of the arc.

    • start_angle

      Start angle for the arc, in radians.

    • end_angle

      End angle for the arc, in radians.

    • num_segments

      How many segments to draw.

    Returns:

    • edges - an array of Edge objects that define the arc.

Version:

  • SketchUp 6.0

#add_circle(center, normal, radius, numsegs = 24) ⇒ Object

The add_circle method is used to create a circle.

Examples:

centerpoint = Geom::Point3d.new
# Create a circle perpendicular to the normal or Z axis
vector = Geom::Vector3d.new 0,0,1
vector2 = vector.normalize!
model = Sketchup.active_model
entities = model.active_entities
edges = entities.add_circle centerpoint, vector2, 10

Returns circle - an Array object containing edges if successful

Parameters:

  • center

    A Point3d object representing the center .

  • normal

    A Vector3d object representing normal for the arc.

  • radius

    The radius of the arc.

  • numsegs (defaults to: 24)

    The number of segments.

Returns:

  • circle - an Array object containing edges if successful

Version:

  • SketchUp 6.0

#add_cline(start_point, end_point, stipple) ⇒ Object

The add_cline method is used to create a construction line.

Examples:

model = Sketchup.active_model
entities = model.active_entities
point1 = Geom::Point3d.new(0, 0, 0)
point2 = Geom::Point3d.new(20, 20, 20)
cline = entities.add_cline(point1, point2)

Returns construction_line - a ConstructionLine object if successful

Parameters:

  • start_point

    A Point3d object where the line will start.

  • end_point

    If a Vector3d, then an infinite line passing through the start_point will be created in that direction. If a Point3d, then a finite line will be created between the two points.

  • stipple (optional)

    Stipple pattern. See ConstructionLine.stipple for acceptable patterns.

Returns:

  • construction_line - a ConstructionLine object if successful

Version:

  • SketchUp 6.0

#add_cpoint(point) ⇒ Object

The add_cpoint method is used to create a construction point.

Examples:

model = Sketchup.active_model
entities = model.active_entities
point1 = Geom::Point3d.new(100,200,300)
constpoint = entities.add_cpoint point1
if (constpoint)
  UI.messagebox constpoint
else
  UI.messagebox "Failure"
end

Returns construction_point - a ConstructionPoint object if successful

Parameters:

  • point

    A Point3d object.

Returns:

  • construction_point - a ConstructionPoint object if successful

Version:

  • SketchUp 6.0

#add_curve(pts_or_array) ⇒ Object

The add_curve method is used to create a curve from a collection of edges.

The arguments are either Points or an Array of Points. At least 2 points are required.

Examples:

entities = Sketchup.active_model.entities
curve = entities.add_curve [0,0,0], [0,10,0], [1,20,0]

Returns curve - an array of Edges that make up the curve if successful

Parameters:

  • pts_or_array

    You can pass either a series of Point3d objects or a single array containing Point3d objects.

Returns:

  • curve - an array of Edges that make up the curve if successful

Version:

  • SketchUp 6.0

#add_dimension_linear(start_pt_or_entity, end_pt_or_entity, offset_vector) ⇒ Object

The add_dimension_linear method adds a linear dimension to the entities.

Examples:

entities = Sketchup.active_model.entities
# From point to point
dim = entities.add_dimension_linear [50, 10, 0], [100, 10, 0], [0, 20, 0]
# Between edge vertices
edge = entities.add_edges([50,50,0], [40,10,0])[0]
v0 = edge.start
v1 = edge.end
dim = entities.add_dimension_linear v0, v1, [0, 0, 20]
# From an edge's midpoint to a construction point
p0 = edge.start.position
p1 = edge.end.position
mp = Geom::Point3d.new((p0.x+p1.x)/2.0, (p0.y+p1.y)/2.0, (p0.z+p1.z)/2.0)
cp = entities.add_cpoint [50, 10, 0]
dim = entities.add_dimension_linear [edge, mp], cp, [20, 0, 0]
# alternatively, the start params could be passed in separately
dim = entities.add_dimension_linear edge, mp, cp, [20, 0, 0]
  • an InputPoint

    - a Point3d
    - a Vertex
    - a ConstructionPoint
    - an array of size 2: [Edge, Point3d along the edge].
      Alternatively, these can be passed in as separate
      parameters, turning this parameter into 2 parameters.
    - an array of size 2: [ConstructionLine, Point3d along
      the line] Alternatively, these can be passed in as
      separate parameters, turning this parameter into 2
      parameters.

Parameters:

  • start_pt_or_entity

    the reference point and/or entity at the start of the dimension. This parameter can take several forms:

  • end_pt_or_entity

    the reference point and/or entity at the end of the dimension. This parameter takes the exact same forms as 'start_pt_or_entity'.

  • offset_vector

    the parallel offset vector from the reference line to the dimension line measured from the 'start' reference point.

Returns:

  • Entity - the created dimension

Version:

  • SketchUp 2014

#add_dimension_radial(arc_curve, leader_break_pt) ⇒ Object

The add_dimension_radial method adds a radial dimension (i.e arc/circle radius/diameter dimension) to the entities.

Examples:

entities = Sketchup.active_model.entities
# Create a circle
centerpoint = Geom::Point3d.new(10, 10, 0)
vector = Geom::Vector3d.new(0, 0, 1)
edges = entities.add_circle centerpoint, vector, 10
circle = edges[0].curve
dim = entities.add_dimension_radial circle, [30, 30, 0]

Returns the created dimension

Parameters:

  • arc_curve

    an ArcCurve object to which the dimension is to be attached.

  • leader_break_pt

    a Point3d for the break point on the leader where the dimension text is attached.

Returns:

  • the created dimension

Version:

  • SketchUp 2014

#add_edges(pts_or_array) ⇒ Object

The add_edges method is used to add a set of connected edges to the entities array.

Examples:

model = Sketchup.active_model
entities = model.active_entities
point1 = Geom::Point3d.new(0,0,0)
point2 = Geom::Point3d.new(20,20,20)
edges = entities.add_edges point1, point2

Returns edges - an array of Edge objects if successful

Parameters:

  • pts_or_array

    You can pass either a series of Point3d objects or a single array containing Point3d objects.

Returns:

  • edges - an array of Edge objects if successful

Version:

  • SketchUp 6.0

#add_face(some_entities) ⇒ Object

The add_face method is used to create a face. You can call this method a number of ways:

- entities.add_face(edge1, edge2, edge3, ...)
- entities.add_face(edgearray)
- entities.add_face(pt1, pt2, pt3, ...)
- entities.add_face([pt1, pt2, pt3,...])
- entities.add_face(curve)

For the last form that takes a Curve, the curve must be closed - like a circle.

Note that a special case exists for any face created on the ground plane, in which case the vertex order is ignored and the face is always facing down.

Examples:

depth = 100
width = 100
model = Sketchup.active_model
entities = model.active_entities
pts = []
pts[0] = [0, 0, 0]
pts[1] = [width, 0, 0]
pts[2] = [width, depth, 0]
pts[3] = [0, depth, 0]
# Add the face to the entities in the model
face = entities.add_face pts
if (face)
  UI.messagebox face
else
  UI.messagebox "Failure"
end

Returns face - a Face object if successful

Parameters:

  • some_entities

    Either a series of Edge or Point3d objects, an array of Point3d objects, or a closed Curve.

Returns:

  • face - a Face object if successful

Version:

  • SketchUp 6.0

#add_faces_from_mesh(polygon_mesh, smooth_flags = Geom::PolygonMesh::AUTO_SOFTEN|Geom::PolygonMesh::SMOOTH_SOFT_EDGES, f_material = nil, b_material = nil) ⇒ Integer

The #add_faces_from_mesh method is used to add Face objects to the collection of entities from a PolygonMesh.

The smooth_flags parameter can contain any of the following values if passed. The constants were added in SketchUp 2014. For previous versions, numeric values have to be specified instead of the Ruby constants.

The 3rd and 4th parameters will accept a Sketchup::Entities.sketchupsketchup::Material object or a string name of a material currently in the model.

Examples:

pm = Geom::PolygonMesh.new
pm.add_point([ 0, 0, 0]) # 1
pm.add_point([10, 0, 0]) # 2
pm.add_point([10,10, 0]) # 3
pm.add_point([ 0,10, 0]) # 4
pm.add_point([20, 0, 5]) # 5
pm.add_point([20,10, 5]) # 6
pm.add_polygon(1, -2, 3, 4)
pm.add_polygon(2, 5,6, -3)

# Create a new group that we will populate with the mesh.
group = Sketchup.active_model.entities.add_group
material = Sketchup.active_model.materials.add('green')
smooth_flags = Geom::PolygonMesh::NO_SMOOTH_OR_HIDE
group.entities.add_faces_from_mesh(pm, smooth_flags, material)

Returns Number of faces created

Parameters:

  • polygon_mesh (Geom::PolygonMesh)
  • smooth_flags (Integer) (defaults to: Geom::PolygonMesh::AUTO_SOFTEN|Geom::PolygonMesh::SMOOTH_SOFT_EDGES)

    flags for softening and smoothing of edges.

  • f_material (Sketchup::Material, String) (defaults to: nil)

    material to paint front faces with.

  • b_material (Sketchup::Material, String) (defaults to: nil)

    material to paint back faces with.

Returns:

  • (Integer)

    Number of faces created

Version:

  • SketchUp 6.0

#add_group(entities) ⇒ Object

The add_group method is used to create an empty group or a group with entities.

NOTE: calling add_group with entities in its parameters has been known to crash SketchUp before version 8.0. It is preferable to create an empty group and then add things to its Entities collection.

Examples:

model = Sketchup.active_model
entities = model.active_entities
group = entities.add_group
if (group)
  UI.messagebox group
else
  UI.messagebox "Failure"
end

Returns group - the new group

Parameters:

  • entities (optional)

    an entities collection to add to the group.

Returns:

  • group - the new group

Version:

  • SketchUp 6.0

#add_image(filename, point, width, height) ⇒ Object

The add_image method is used to add an image to the collection of entities.

The width and height are measured in model units (i.e. inches). If the height is not given, then it is computed from the width to preserve the aspect ratio of the image.

Examples:

model = Sketchup.active_model
entities = model.active_entities
point = Geom::Point3d.new 10,20,30
image = entities.add_image "Shapes.jpg", point, 300
if (image)
  UI.messagebox image
else
  UI.messagebox "Failure"
end

Returns image - an Image object if successful.

Parameters:

  • filename

    A filename for the image file.

  • point

    A Point3d object representing the insertion point of the image.

  • width

    Width for the image.

  • height (optional)

    height for the image if you want to control width and height independently.

Returns:

  • image - an Image object if successful.

Version:

  • SketchUp 6.0

#add_instance(definition, transform) ⇒ Object

The add_instance method adds a component instance to the collection of entities.

Examples:

point = Geom::Point3d.new 10,20,30
transform = Geom::Transformation.new point
model = Sketchup.active_model
entities = model.active_entities
path = Sketchup.find_support_file "Bed.skp",
  "Components/Components Sampler/"
definitions = model.definitions
componentdefinition = definitions.load path
instance = entities.add_instance componentdefinition, transform
if (instance)
  UI.messagebox instance
else
  UI.messagebox "Failure"
end

Returns componentinstance - a ComponentInstance object if successful

Parameters:

  • definition

    A ComponentDefinition object.

  • transform

    A Transformation object.

Returns:

  • componentinstance - a ComponentInstance object if successful

Version:

  • SketchUp 6.0

#add_line(point1, point2) ⇒ Object

The add_line method is used to add an edge to the collection of entities. This is not to be confused with the concept of a “line” from a geometric sense, which is an invisible object represented by an Array of a point and a vector. (See the Array class for more information on geometric lines in SketchUp.)

This method is the same as add_edges method, but returns a single edge.

Examples:

model = Sketchup.active_model
entities = model.active_entities
point1 = Geom::Point3d.new(0,0,0)
point2 = Geom::Point3d.new(20,20,20)
line = entities.add_line point1,point2
if (line)
  UI.messagebox line
else
  UI.messagebox "Failure"
end

Returns edge - a Edge object if successful

Parameters:

  • point1

    Point3d object representing the edge's starting point.

  • point2

    Point3d object representing the edge's ending point.

Returns:

  • edge - a Edge object if successful

Version:

  • SketchUp 6.0

#add_ngon(center, normal, radius, numsides = 24) ⇒ Object

The add_ngon method is used to create a multi-sided polygon.

Examples:

entities = Sketchup.active_model.entities
center = Geom::Point3d.new
normal = Geom::Vector3d.new(0,0,1)
radius = 100
numsides = 6
edges = entities.add_ngon center, normal, radius, numsides

Returns edges - an array of Edges that make up the polygon if successful

Parameters:

  • center

    A Point3d object representing the center of the polygon.

  • normal

    A Vector3d object.

  • radius

    A radius.

  • numsides (defaults to: 24)

    The number of sides for the polygon.

Returns:

  • edges - an array of Edges that make up the polygon if successful

Version:

  • SketchUp 6.0

#add_observer(observer) ⇒ Object

The add_observer method is used to add an observer to the current object.

Examples:

entities = Sketchup.active_model.entities
status = entities.add_observer observer

Returns true if successful, false if unsuccessful.

Parameters:

  • observer

    An observer.

Returns:

  • true if successful, false if unsuccessful.

Version:

  • SketchUp 6.0

#add_section_plane(plane) ⇒ Object

The add_section_plane method adds a section plane object to the entities.

Examples:

# Create a section plane
model = Sketchup.active_model
sp = model.entities.add_section_plane([50, 50, 0], [1.0, 1.0, 0])
# Activate it
sp.activate
# Make sure section planes are visible
model.rendering_options['DisplaySectionPlanes'] = true

Returns the created SectionPlane object if successful, nil on failure.

Parameters:

  • plane

    the geometric plane where the SectionPlane object is to be created. Refer to the Geom module for information on how planes are represented.

Returns:

  • the created SectionPlane object if successful, nil on failure.

Version:

  • SketchUp 2014

#add_text(text, point, vector) ⇒ Object

The add_text method adds a note or label text entity to the entities

Examples:

coordinates = [10, 10, 10]
model = Sketchup.active_model
entities = model.entities
point = Geom::Point3d.new coordinates
text = entities.add_text "This is a Test", point

Returns text - a Text object if successful

Parameters:

  • text

    The text string to add.

  • point

    A Point3d object representing the insertion point.

  • vector (optional)

    vector representing an arrow leader.

Returns:

  • text - a Text object if successful

Version:

  • SketchUp 6.0

#at(entity_index) ⇒ Sketchup::Entity?

The #at method is an alias for #[].

Examples:

entities = Sketchup.active_model.entities
entity = entities.at(0)

Returns:

See Also:

Version:

  • SketchUp 6.0

#clear!Object

The clear! method is used to remove all entities from the collection of entities.

Examples:

coordinates = [10, 10, 10]
model = Sketchup.active_model
entities = model.entities
point = Geom::Point3d.new coordinates
text = entities.add_text "This is a Test", point
UI.messagebox "Clearing All"
status = entities.clear!

Returns:

  • status - true if successful, false if unsuccessful

Version:

  • SketchUp 6.0

#countInteger

Note:

Since SketchUp 2014 the count method is inherited from Ruby's Enumable mix-in module. Prior to that the #count method is an alias for #length.

Examples:

model = Sketchup.active_model
entities = model.entities
entities.add_cpoint([10, 10, 10])
number = entities.count

Returns:

  • (Integer)

See Also:

Version:

  • SketchUp 6.0

#each {|entity| ... } ⇒ Object

The each method is used to iterate through the entities in the collection of entities.

Examples:

coordinates = [10, 10, 10]
model = Sketchup.active_model
entities = model.entities
point = Geom::Point3d.new coordinates
text = entities.add_text "This is a Test", point
entities.each { | entity| UI.messagebox entity }

Yields:

  • (entity)

    A variable that will hold each Entity object as they are found if successful.

Returns:

  • nil

Version:

  • SketchUp 6.0

#erase_entities(entities) ⇒ Object

The erase_entities method is used to erase one or more entities from the model.

Examples:

depth = 100
width = 100
model = Sketchup.active_model
entities = model.active_entities
pts = []
pts[0] = [0, 0, 0]
pts[1] = [width, 0, 0]
pts[2] = [width, depth, 0]
pts[3] = [0, depth, 0]

# Add the face to the entities in the model
face = entities.add_face pts

# I just happen to know that the second entity in the
# entities objects is an edge, so erase it.
UI.messagebox entities
entities.erase_entities entities[1]
UI.messagebox entities

Returns nil

Parameters:

  • entities

    An entity or array of entities.

Returns:

  • nil

Version:

  • SketchUp 6.0

#fill_from_mesh(polygon_mesh, weld_vertices = true, smooth_flags = Geom::PolygonMesh::AUTO_SOFTEN|Geom::PolygonMesh::SMOOTH_SOFT_EDGES, f_material = nil, b_material = nil) ⇒ Boolean

The #fill_from_mesh method is used to add faces and edges to the collection of entities from a Geom::PolygonMesh. It requires that the entities collection to be filled is empty. It has higher performance than #add_faces_from_mesh, but does less error checking as it builds the geometry.

The smooth_flags parameter can contain any of the following values if passed. The constants were added in SketchUp 2014. For previous versions, numeric values have to be specified instead of the Ruby constants:

The 4rd and 5th parameters will accept a Material object or a string name of a material currently in the model.

Examples:

pm = Geom::PolygonMesh.new
pm.add_point([ 0, 0, 0]) # 1
pm.add_point([10, 0, 0]) # 2
pm.add_point([10,10, 0]) # 3
pm.add_point([ 0,10, 0]) # 4
pm.add_point([20, 0, 5]) # 5
pm.add_point([20,10, 5]) # 6
pm.add_polygon(1, -2, 3, 4)
pm.add_polygon(2, 5, 6, -3)

# Create a new group that we will populate with the mesh.
group = Sketchup.active_model.entities.add_group
material = Sketchup.active_model.materials.add('red')
smooth_flags = Geom::PolygonMesh::HIDE_BASED_ON_INDEX
group.entities.fill_from_mesh(pm, true, smooth_flags, material)

Parameters:

  • polygon_mesh (Geom::PolygonMesh)
  • weld_vertices (Boolean) (defaults to: true)

    This argument has no effect and is kept for compatibility reasons. Points are always merged.

  • smooth_flags (Integer) (defaults to: Geom::PolygonMesh::AUTO_SOFTEN|Geom::PolygonMesh::SMOOTH_SOFT_EDGES)

    flags for softening and smoothing of edges.

  • f_material (Sketchup::Material, String) (defaults to: nil)

    material to paint front faces with.

  • b_material (Sketchup::Material, String) (defaults to: nil)

    material to paint back faces with.

Returns:

  • (Boolean)

Version:

  • SketchUp 6.0

#intersect_with(recurse, transform1, entities1, transform2, hidden, entities2) ⇒ Object

The intersect_with method is used to intersect an entities, component instance, or group object with a entities object.

Examples:

entities.intersect_with recurse, transformation1, entities1,
  transformation2, hidden, entities2

Returns nil

Parameters:

  • recurse

    true if you want this entities object to be recursed (intersection lines will be put inside of groups and components within this entities object).

  • transform1

    The transformation for this entities object.

  • entities1

    The entities object where you want the intersection lines to appear.

  • transform2

    The transformation for entities1.

  • hidden

    true if you want hidden geometry in this entities object to be used in the intersection.

  • entities2

    A single entity, or an array of entities.

Returns:

  • nil

Version:

  • SketchUp 6.0

#lengthInteger

The #length method is used to retrieve the number of entities in the collection of entities.

Examples:

model = Sketchup.active_model
entities = model.entities
entities.add_cpoint([10, 10, 10])
number = entities.length

Returns:

  • (Integer)

See Also:

Version:

  • SketchUp 6.0

#modelObject

The model method is used to retrieve the model that contains the collection of entities.

Examples:

coordinates = [10, 10, 10]
model = Sketchup.active_model
entities = model.entities
point = Geom::Point3d.new coordinates
text = entities.add_text "This is a Test", point
model = entities.model

Returns:

  • model - the model that contains the collection of entities if successful.

Version:

  • SketchUp 6.0

#parentObject

The parent method is used to retrieve the parent or object that contains the collection of entities. A parent can be either a Model or ComponentDefinition object.

Examples:

coordinates = [10, 10, 10]
model = Sketchup.active_model
entities = model.entities
point = Geom::Point3d.new coordinates
text = entities.add_text "This is a Test", point
parent = entities.parent

Returns:

  • parent - the object that contains the collection of entities if successful

Version:

  • SketchUp 6.0

#remove_observer(observer) ⇒ Object

The remove_observer method is used to remove an observer from the current object.

Examples:

entities = Sketchup.active_model.entities
status = entities.remove_observer observer

Returns true if successful, false if unsuccessful.

Parameters:

  • observer

    An observer.

Returns:

  • true if successful, false if unsuccessful.

Version:

  • SketchUp 6.0

#sizeInteger

The #size method is an alias for the #length method.

Examples:

model = Sketchup.active_model
entities = model.entities
entities.add_cpoint([10, 10, 10])
number = entities.size

Returns:

  • (Integer)

See Also:

Version:

  • SketchUp 2014

#transform_by_vectors(sub_entities, vectors) ⇒ Object

The transform_by_vectors method is used to apply several vectors to several sub-entities all at once.

Examples:

# Need better Ruby example.
entities = entities.transform_by_vectors sub_entities, vector_array

Returns nil

Parameters:

  • sub_entities

    An array of entities to transform.

  • vectors

    An array of vectors to apply.

Returns:

  • nil

Version:

  • SketchUp 6.0

#transform_entities(transform, entities) ⇒ Object

The transform_entities method is used to apply a transform to several sub-entities all at once.

Important note: If you apply a transformation to entities that are not in the current edit context (i.e. faces that are inside a group), SketchUp will apply the transformation incorrectly, since the geometry has one origin and the current edit context has another. You can correct for this by watching the Model.edit_transform and Model.active_path. See ModelObserver.onActivePathChanged for more information.

Examples:

entities = Sketchup.active_model.entities
entities.add_line([0,0,0],[100,100,100])
entities.add_line([0,0,0],[200,-10,-10])

entities_to_transform = []
entities_to_transform.push(entities[0])
entities_to_transform.push(entities[1])

transform = Geom::Transformation.new([100,0,0])
entities.transform_entities(transform, ent1, ent2, ent3)

Returns status - results of the transform.

Parameters:

  • transform

    The Transformation to apply.

  • entities

    An array or series of entities to transform.

Returns:

  • status - results of the transform.

Version:

  • SketchUp 6.0