Class: Sketchup::Entities
| Relationships | |
| Super Chains via Extension / Inclusion / Inheritance | |
|
Instance Chain:
self,
Enumerable
|
|
| Inherits: | Object |
Overview
The Entities class is a collection of Entity objects, either in a
ComponentDefinition or directly in the Model. A
Entities object corresponds to a drawing context in the GUI.
Instance Attribute Summary
-
#active_section_plane ⇒ Sketchup::SectionPlane?
rw
The active_section_plane method is used to access the currently active section plane in the
Entitiesobject. -
#active_section_plane=(sec_plane) ⇒ Sketchup::SectionPlane?
rw
The active_section_plane= method is used to set the active section plane in the
Entitiesobject.
Instance Method Summary
-
#[](entity_index) ⇒ Sketchup::Entity?
The #[] method is used to retrieve an entity by its index in an array of entities.
-
#add_3d_text(string, alignment, font, is_bold = false, is_italic = false, letter_height = 1.0, tolerance = 0.0, z = 0.0, is_filled = true, extrusion = 0.0) ⇒ Boolean
The #add_3d_text method is used to create 3D text.
-
#add_arc(center, xaxis, normal, radius, start_angle, end_angle) ⇒ Array<Sketchup::Edge>
The add_arc method is used to create an arc curve segment.
-
#add_circle(center, normal, radius, numsegs = 24) ⇒ Array<Sketchup::Edge>
The add_circle method is used to create a circle.
-
#add_cline(start_point, end_point, stipple = '-') ⇒ Sketchup::ConstructionLine
The #add_cline method is used to create a construction line.
-
#add_copy(entities, transform: IDENTITY) ⇒ Array<Sketchup::Drawingelement>
The #add_copy method copies a set of drawing elements into this
Entitiescollection. -
#add_cpoint(point) ⇒ Sketchup::ConstructionPoint
The add_cpoint method is used to create a construction point.
-
#add_curve(points) ⇒ Array<Sketchup::Edge>
The add_curve method is used to create a curve from a collection of edges.
-
#add_dimension_linear(start_pt_or_entity, end_pt_or_entity, offset_vector) ⇒ Sketchup::DimensionLinear
The #add_dimension_linear method adds a linear dimension to the entities.
-
#add_dimension_radial(arc_curve, leader_break_pt) ⇒ Sketchup::DimensionRadial
The add_dimension_radial method adds a radial dimension (i.e arc/circle radius/diameter dimension) to the entities.
-
#add_edges(points) ⇒ Array<Sketchup::Edge>
The #add_edges method is used to add a set of connected edges to the
Entitiescollection. -
#add_face(entities) ⇒ Sketchup::Face?
The add_face method is used to create a face.
-
#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
Faceentities to the collection of entities from a::Geom::PolygonMesh. -
#add_group(entities) ⇒ Sketchup::Group
The #add_group method is used to create a new group.
-
#add_image(path, point, width, height = 0.0) ⇒ Sketchup::Image?
The add_image method is used to add an image to the collection of entities.
-
#add_instance(definition, transform) ⇒ Sketchup::ComponentInstance
The #add_instance method adds a group or component instance to the collection of entities using an existent definition.
-
#add_line(point1, point2) ⇒ Sketchup::Edge
The add_line method is used to add an edge to the collection of entities.
-
#add_ngon(center, normal, radius, numsides = 24) ⇒ Array<Sketchup::Edge>
The add_ngon method is used to create a multi-sided polygon.
-
#add_observer(observer) ⇒ Boolean
The add_observer method is used to add an observer to the current object.
-
#add_section_plane(point, vector) ⇒ Sketchup::SectionPlane?
Adds a section plane object to the entities.
- #add_snap(position, direction) ⇒ Sketchup::Snap
-
#add_text(text, point, vector) ⇒ Sketchup::Text
The #add_text method adds a note or label text entity to the entities.
- #at(entity_index) ⇒ Sketchup::Entity?
-
#bounds ⇒ Geom::BoundingBox
The #bounds method is used to retrieve the
::Geom::BoundingBoxbounding the collection of entities. -
#build {|builder| ... } ⇒ nil
Creates an
EntitiesBuilderthat can be used to generate bulk geometry with performance in mind. -
#clear! ⇒ Boolean
The clear! method is used to remove all entities from the collection of entities.
- #count ⇒ Integer
-
#each {|entity| ... } ⇒ nil
The #each method is used to iterate through the entities in the collection of entities.
-
#erase_entities(entities) ⇒ nil
The #erase_entities method is used to erase one or more entities from the model.
-
#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. -
#intersect_with(recurse, transform1, entities1, transform2, hidden, entities2) ⇒ Array<Sketchup::Edge>
The #intersect_with method computes the intersections between two sets of entities in different 3D contexts and creates the resulting intersection edges in a third context.
-
#length ⇒ Integer
The #length method is used to retrieve the number of entities in the collection of entities.
-
#model ⇒ Sketchup::Model
The model method is used to retrieve the model that contains the collection of entities.
-
#parent ⇒ Sketchup::ComponentDefinition, Sketchup::Model
The parent method is used to retrieve the parent or object that contains the collection of entities.
-
#remove_observer(observer) ⇒ Boolean
The remove_observer method is used to remove an observer from the current object.
- #size ⇒ Integer
-
#transform_by_vectors(sub_entities, vectors) ⇒ Sketchup::Entities
The transform_by_vectors method is used to apply several vectors to several sub-entities all at once.
-
#transform_entities(transform, entities) ⇒ Boolean
The transform_entities method is used to apply a transform to several sub-entities all at once.
- #weld(edges) ⇒ Array<Sketchup::Curve>
Instance Attribute Details
#active_section_plane ⇒ Sketchup::SectionPlane? (rw)
The active_section_plane method is used to access the currently active
section plane in the Entities object.
#active_section_plane=(sec_plane) ⇒ Sketchup::SectionPlane? (rw)
The active_section_plane= method is used to set the active section plane in
the Entities object.
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.
#add_3d_text(string, alignment, font, is_bold = false, is_italic = false, letter_height = 1.0, tolerance = 0.0, z = 0.0, is_filled = true, extrusion = 0.0) ⇒ Boolean
The #add_3d_text method is used to create 3D text. It will be added as edges and
faces drawn at the origin.
#add_arc(center, xaxis, normal, radius, start_angle, end_angle) ⇒ Array<Sketchup::Edge>
#add_arc(center, xaxis, normal, radius, start_angle, end_angle, num_segments) ⇒ Array<Sketchup::Edge>
The add_arc method is used to create an arc curve segment.
#add_circle(center, normal, radius, numsegs = 24) ⇒ Array<Sketchup::Edge>
The add_circle method is used to create a circle.
#add_cline(start_point, end_point, stipple = '-') ⇒ Sketchup::ConstructionLine
#add_cline(point, vector, stipple = '-') ⇒ Sketchup::ConstructionLine
The #add_cline method is used to create a construction line. This can be
finite or infinite.
#add_copy(entities, transform: IDENTITY) ⇒ Array<Sketchup::Drawingelement>
The #add_copy method copies a set of drawing elements into this Entities
collection.
Source elements' geometric coordinates from within their parent components are preserved, and they are applied to the copies in this component's local coordinate frame. The transformation is also interpreted to be in the local coordinates of this (target) component.
The drawing elements being copied may already belong to this collection or to a different one, but they must all share the same parent, and belong to the same model as this collection. Dependent geometry needed to reproduce the originals (e.g. the edges bounding a copied face) are copied automatically and included in the result.
#add_cpoint(point) ⇒ Sketchup::ConstructionPoint
The add_cpoint method is used to create a construction point.
#add_curve(points) ⇒ Array<Sketchup::Edge>
#add_curve(*points) ⇒ Array<Sketchup::Edge>
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.
#add_dimension_linear(start_pt_or_entity, end_pt_or_entity, offset_vector) ⇒ Sketchup::DimensionLinear
#add_dimension_linear(start_instance_path, end_instance_path, offset_vector) ⇒ Sketchup::DimensionLinear
#add_dimension_linear(start_array, end_array, offset_vector) ⇒ Sketchup::DimensionLinear
The #add_dimension_linear method adds a linear dimension to the entities.
#add_dimension_radial(arc_curve, leader_break_pt) ⇒ Sketchup::DimensionRadial
The add_dimension_radial method adds a radial dimension (i.e arc/circle radius/diameter dimension) to the entities.
#add_edges(points) ⇒ Array<Sketchup::Edge>
#add_edges(*points) ⇒ Array<Sketchup::Edge>
If the points form a closed loop, the first and last vertex will not merge. If you intend to create a face from the edges, use #add_face directly.
The #add_edges method is used to add a set of connected edges to the
Entities collection.
#add_face(entities) ⇒ Sketchup::Face?
#add_face(*entities) ⇒ Sketchup::Face?
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.
When using the edge array or curve overload this method will return nil and abort any
open operation if:
- The edges do not form a closed loop
- The edges are not planar
In these cases use
$!to check for an error message if the face creation fails.
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.
#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 entities to the
collection of entities from a ::Geom::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.
- 0: Geom::PolygonMesh::NO_SMOOTH_OR_HIDE
- 1: Geom::PolygonMesh::HIDE_BASED_ON_INDEX (Negative point index will hide the edge.)
- 2: Geom::PolygonMesh::SOFTEN_BASED_ON_INDEX (Negative point index will soften the edge.)
- 4: Geom::PolygonMesh::AUTO_SOFTEN (Interior edges are softened.)
- 8: Geom::PolygonMesh::SMOOTH_SOFT_EDGES (All soft edges will also be smooth.)
The 3rd and 4th parameters will accept a Material object or a
string name of a material currently in the model.
#add_group(entities) ⇒ Sketchup::Group
#add_group(*entities) ⇒ Sketchup::Group
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.
The #add_group method is used to create a new group.
#add_image(path, point, width, height = 0.0) ⇒ Sketchup::Image?
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.
#add_instance(definition, transform) ⇒ Sketchup::ComponentInstance
The #add_instance method adds a group or component instance to the collection of
entities using an existent definition.
#add_line(point1, point2) ⇒ Sketchup::Edge
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.
#add_ngon(center, normal, radius, numsides = 24) ⇒ Array<Sketchup::Edge>
The add_ngon method is used to create a multi-sided polygon.
#add_observer(observer) ⇒ Boolean
The add_observer method is used to add an observer to the current object.
#add_section_plane(point, vector) ⇒ Sketchup::SectionPlane?
#add_section_plane(plane) ⇒ Sketchup::SectionPlane?
#add_section_plane(plane) ⇒ Sketchup::SectionPlane?
Adds a section plane object to the entities.
Refer to the ::Geom module for information on how planes are represented.
#add_snap(position, direction) ⇒ Sketchup::Snap
#add_snap(position, direction, up) ⇒ Sketchup::Snap
The #add_snap method is used to create a new Snap.
#add_text(text, point, vector) ⇒ Sketchup::Text
#add_text(text, instance_path_and_pt, vector) ⇒ Sketchup::Text
#add_text(text, instance_array_and_pt, vector) ⇒ Sketchup::Text
The #add_text method adds a note or label text entity to the entities.
#at(entity_index) ⇒ Sketchup::Entity?
The #at method is an alias for #[].
#bounds ⇒ Geom::BoundingBox
The #bounds method is used to retrieve the ::Geom::BoundingBox bounding
the collection of entities.
For a Procedural Component, ComponentDefinition#entities and
ComponentDefinition#control_entities have different bounds.
For non-procedural components this has the same effect as
Sketchup::ComponentDefinition#bounds.
#build {|builder| ... } ⇒ nil
While using build it is important to not
add or remove vertices by other means than the builder. Also don't modify the
position of the vertices in the Entities collection. Doing so can break the
vertex-cache that de-duplicates the vertices.
Creates an EntitiesBuilder that can be used to generate bulk
geometry with performance in mind. This is particularly useful for importers
where the geometry is already well defined and one wants to recreate it
without further processing.
The call to #build starts an implicit operation, even if no other model
changes are made within the block. This is not the same as
Model#start_operation, so it's still recommended to wrap all
model changes, including #build with Model#start_operation and
Model#commit_operation.
Refer to the documentation of EntitiesBuilder for more details.
#clear! ⇒ Boolean
The clear! method is used to remove all entities from the collection of entities.
#count ⇒ Integer
Since SketchUp 2014 the count method is inherited from Ruby's
Enumerable mix-in module. Prior to that the #count method is an alias
for #length.
#each {|entity| ... } ⇒ nil
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 is used to iterate through the entities in the collection
of entities.
#erase_entities(entities) ⇒ nil
#erase_entities(*entities) ⇒ nil
nil
#erase_entities(*entities) ⇒ nil
It's faster to use this method and erase in bulk than to iterate individual drawing elements calling Drawingelement#erase!.
The #erase_entities method is used to erase one or more entities from the
model.
#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:
- 0: Geom::PolygonMesh::NO_SMOOTH_OR_HIDE
- 1: Geom::PolygonMesh::HIDE_BASED_ON_INDEX (Negative point index will hide the edge.)
- 2: Geom::PolygonMesh::SOFTEN_BASED_ON_INDEX (Negative point index will soften the edge.)
- 4: Geom::PolygonMesh::AUTO_SOFTEN (Interior edges are softened.)
- 8: Geom::PolygonMesh::SMOOTH_SOFT_EDGES (All soft edges will also be smooth.)
The 4rd and 5th parameters will accept a Material object or a
string name of a material currently in the model.
#intersect_with(recurse, transform1, entities1, transform2, hidden, entities2) ⇒ Array<Sketchup::Edge>
The #intersect_with method computes the intersections between two sets of
entities in different 3D contexts and creates the resulting intersection
edges in a third context.
This powerful method operates on three distinct sets of entities:
-
The Receiver (+self+): The
Entitiescollection the method is called on. -
The Cutting
Entities(+entities2+): The entities that intersect with the receiver. -
The Result Container (+entities1+): The
Entitiescollection where the new intersection edges are placed.
The transformations transform1 and transform2 are used to relate these
three different contexts to each other, allowing for intersections to be
calculated between objects anywhere in the model hierarchy. The intersection
calculation occurs in a common coordinate space, and the transformations
are used to bring the geometry into that space.
#length ⇒ Integer
The #length method is used to retrieve the number of entities in the
collection of entities.
#model ⇒ Sketchup::Model
The model method is used to retrieve the model that contains the collection of entities.
#parent ⇒ Sketchup::ComponentDefinition, Sketchup::Model
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.
#remove_observer(observer) ⇒ Boolean
The remove_observer method is used to remove an observer from the current object.
#size ⇒ Integer
The #size method is an alias for the #length method.
#transform_by_vectors(sub_entities, vectors) ⇒ Entities
The transform_by_vectors method is used to apply several vectors to several sub-entities all at once.
#transform_entities(transform, entities) ⇒ Boolean
The transform_entities method is used to apply a transform to several sub-entities all at once.
If you are transforming entities in the active drawing context or any of its parent drawing contexts, the transformation will be interpreted as relative to the global coordinate system. Otherwise the transformation will be interpreted as being on the local coordinate system.
#weld(edges) ⇒ Array<Sketchup::Curve>
The #weld method takes a set of edges and find all possible chains of edges
and connect them with a Curve.
A curve will not cross another curve. They will split where multiple curves meet.