Class: Sketchup::Entities
- Inherits:
-
Object
- Object
- Sketchup::Entities
- Includes:
- Enumerable
Overview
The Entities class is a container class for all entities in a model (it is a collection of Entity objects).
Instance Method Summary collapse
-
#[](entity_index) ⇒ Sketchup::Entity?
The #[] method is used to retrieve an entity by its index in an array of entities.
-
#active_section_plane ⇒ Object
The active_section_plane method is used to access the currently active section plane in the Entities object.
-
#active_section_plane(sec_plane) ⇒ Object
The active_section_plane= method is used to set the active section plane in the Entities object.
-
#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.
-
#add_arc(center, xaxis, center, normal, radius, start_angle, end_angle, num_segments) ⇒ Object
The add_arc method is used to create an arc curve segment.
-
#add_circle(center, normal, radius, numsegs = 24) ⇒ Object
The add_circle method is used to create a circle.
-
#add_cline(start_point, end) ⇒ Object
The add_cline method is used to create a construction line.
-
#add_cpoint(point) ⇒ Object
The add_cpoint method is used to create a construction point.
-
#add_curve(pts_or_array) ⇒ Object
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) ⇒ Object
The add_dimension_linear method adds a linear dimension to the entities.
-
#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.
-
#add_edges(pts_or_array) ⇒ Object
The add_edges method is used to add a set of connected edges to the entities array.
-
#add_face(some_entities) ⇒ Object
The add_face method is used to create a face.
-
#add_faces_from_mesh(polymesh, smooth_flags = AUTO_SOFTEN|SMOOTH_SOFT_EDGES, f_material = nil, b_material = nil) ⇒ Object
The add_faces_from_mesh method is used to add Face objects to the collection of entities from a PolygonMesh.
-
#add_group(entities) ⇒ Object
The add_group method is used to create an empty group or a group with entities.
-
#add_image(filename, point, width, height) ⇒ Object
The add_image method is used to add an image to the collection of entities.
-
#add_instance(definition, transform) ⇒ Object
The add_instance method adds a component instance to the collection of entities.
-
#add_line(point1, point2) ⇒ Object
The add_line method is used to add an edge to the collection of entities.
-
#add_ngon(center, normal, radius, numsides = 24) ⇒ Object
The add_ngon method is used to create a multi-sided polygon.
-
#add_observer(observer) ⇒ Object
The add_observer method is used to add an observer to the current object.
-
#add_section_plane(plane) ⇒ Object
The add_section_plane method adds a section plane object to the entities.
-
#add_text(text, point, vector) ⇒ Object
The add_text method adds a note or label text entity to the entities.
-
#at(entity_index) ⇒ Sketchup::Entity?
The #[] method is used to retrieve an entity by its index in an array of entities.
-
#clear! ⇒ Object
The clear! method is used to remove all entities from the collection of entities.
- #count ⇒ Integer
-
#each {|entity| ... } ⇒ Object
The each method is used to iterate through the entities in the collection of entities.
-
#erase_entities(entities) ⇒ Object
The erase_entities method is used to erase one or more entities from the model.
-
#fill_from_mesh(polymesh, weld_vertices, smooth_flags = AUTO_SOFTEN|SMOOTH_SOFT_EDGES, f_material = nil, b_material = nil) ⇒ Object
The fill_from_mesh method is used to add faces and edges to the collection of entities from a PolygonMesh.
-
#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.
-
#length ⇒ Integer
The #length method is used to retrieve the number of entities in the collection of entities.
-
#model ⇒ Object
The model method is used to retrieve the model that contains the collection of entities.
-
#parent ⇒ Object
The parent method is used to retrieve the parent or object that contains the collection of entities.
-
#remove_observer(observer) ⇒ Object
The remove_observer method is used to remove an observer from the current object.
-
#size ⇒ Integer
The #length method is used to retrieve the number of entities in the collection of entities.
-
#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.
-
#transform_entities(transform, entities) ⇒ Object
The transform_entities method is used to apply a transform to several sub-entities all at once.
Instance Method Details
#[](entity_index) ⇒ Sketchup::Entity?
#active_section_plane ⇒ Object
The active_section_plane method is used to access the currently active section plane in the Entities object.
#active_section_plane(sec_plane) ⇒ Object
The active_section_plane= method is used to set the active section plane in the Entities object.
#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.
#add_arc(center, xaxis, center, normal, radius, start_angle, end_angle, num_segments) ⇒ Object
The add_arc method is used to create an arc curve segment.
#add_circle(center, normal, radius, numsegs = 24) ⇒ Object
The add_circle method is used to create a circle.
#add_cline(start_point, end) ⇒ Object
The add_cline method is used to create a construction line.
#add_cpoint(point) ⇒ Object
The add_cpoint method is used to create a construction point.
#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.
#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.
#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.
#add_edges(pts_or_array) ⇒ Object
The add_edges method is used to add a set of connected edges to the entities array.
#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.
#add_faces_from_mesh(polymesh, smooth_flags = AUTO_SOFTEN|SMOOTH_SOFT_EDGES, f_material = nil, b_material = nil) ⇒ Object
The add_faces_from_mesh method is used to add Face objects to the collection of entities from a PolygonMesh.
The 2nd through 4th parameters are optional. 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) ⇒ 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.
#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.
#add_instance(definition, transform) ⇒ Object
The add_instance method adds a component instance to the collection of entities.
#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.
#add_ngon(center, normal, radius, numsides = 24) ⇒ Object
The add_ngon method is used to create a multi-sided polygon.
#add_observer(observer) ⇒ Object
The add_observer method is used to add an observer to the current object.
#add_section_plane(plane) ⇒ Object
The add_section_plane method adds a section plane object to the entities.
#add_text(text, point, vector) ⇒ Object
The add_text method adds a note or label text entity to the entities
#at(entity_index) ⇒ Sketchup::Entity?
#clear! ⇒ Object
The clear! method is used to remove all entities from the collection of entities.
#count ⇒ Integer
#each {|entity| ... } ⇒ Object
The each method is used to iterate through the entities in the collection of entities.
#erase_entities(entities) ⇒ Object
The erase_entities method is used to erase one or more entities from the model.
#fill_from_mesh(polymesh, weld_vertices, smooth_flags = AUTO_SOFTEN|SMOOTH_SOFT_EDGES, f_material = nil, b_material = nil) ⇒ Object
The fill_from_mesh method is used to add faces and edges to the collection of entities from a 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 2nd through 5th parameters are optional. 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) ⇒ Object
The intersect_with method is used to intersect an entities, component instance, or group object with a entities object.
#length ⇒ Integer
#model ⇒ Object
The model method is used to retrieve the model that contains the collection of entities.
#parent ⇒ Object
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) ⇒ Object
The remove_observer method is used to remove an observer from the current object.
#size ⇒ Integer
#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.
#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.