Module: AMS::Group

Defined in:
Documentation/ams/group.rb

Overview

Since:

  • 3.3.0

Class Method Summary collapse

Class Method Details

.calc_centre_of_mass(object, recursive = true, transformation = nil) {|entity| ... } ⇒ Geom::Point3d

Note:

This method returns an improper centre of mass in some cases.

Note:

This function was revised in version 3.5.0.

Calculate group/component instance centre of mass from faces.

Parameters:

  • object (Sketchup::Group, Sketchup::ComponentInstance)

    A group or a component instance.

  • recursive (Boolean) (defaults to: true)

    Whether to include sub-groups and sub-component instances. All points of a sub-element are transformed to object's transformation and then applied a desired transformation.

  • transformation (Geom::Transformation, nil) (defaults to: nil)

    A coordinate system to transform all the points to before computing. Usually this parameter is the coordinate system object is associated to. Pass nil to compute in object's local coordinates.

Yields:

  • A procedure to determine whether a particular face, sub-group, or a sub-component instance, should be considered a part of the operation.

Yield Parameters:

  • entity (Sketchup::Drawingelement)

Yield Returns:

  • (Boolean)

    Pass true to consider an entity a part of the operation; pass false to ignore the entity.

Returns:

  • (Geom::Point3d)

Since:

  • 3.3.0

.copy(object, context = nil, recursive = true, transformation = nil) {|entity| ... } ⇒ Sketchup::Group?

Note:

Make sure to wrap this function with a start/commit operation to avoid polluting the undo stack.

Note:

The original group is not modified in any way.

Note:

Regardless of whether object is a group or a component instance, the resulting entity will always be a group. Same applies to sub-groups and sub-component instances.

Note:

For copied faces:

  • Each is assigned its original front/back material.

  • Each is assigned to Layer0.

  • Attributes are not copied.

  • Casts/receives shadows and visibility state are not retained; they will depend on the parent group/component properties.

Note:

For copied edges:

  • Each is assigned its original soft/smooth options.

  • Each is assigned to Layer0.

  • Attributes are not copied.

  • Casts/receives shadows and visibility state are not retained; they will depend on the parent group/component properties.

Note:

For copied construction points and lines:

  • Each is assigned its original layer.

  • Attributes are not copied.

Note:

For copied group and sub-groups:

  • Each is assigned its original name, layer, material, visibility state, casts/receives shadows state, and transformation.

  • Attributes are not copied.

Note:

This function was revised in version 3.5.0.

Note:

Tiny faces with loops don't always replicate properly.

Copy group/component instance without including the undesired entities.

Parameters:

  • object (Sketchup::Group, Sketchup::ComponentInstance)

    A group or a component instance.

  • context (Sketchup::Entities, nil) (defaults to: nil)

    The entities context to paste to. Pass nil to paste to the context object is associated to.

  • recursive (Boolean) (defaults to: true)

    Whether to include sub-groups and sub-component instances.

  • transformation (Geom::Transformation, nil) (defaults to: nil)

    A transformation matrix, relative to context, to apply to the resulting group. Pass nil to have the resulting group be applied the matrix of object.

Yields:

  • A procedure to determine whether a particular edge, face, construction point, construction line, sub-group, or a sub-component instance, should be considered a part of the operation.

Yield Parameters:

  • entity (Sketchup::Drawingelement)

Yield Returns:

  • (Boolean)

    Pass true to consider an entity a part of the operation; pass false to ignore the entity.

Returns:

  • (Sketchup::Group, nil)

    A copied group or nil if nothing copied.

Since:

  • 3.3.0

.get_bounding_box_from_edges(object, recursive = true, transformation = nil) {|entity| ... } ⇒ Geom::BoundingBox

Get group/component instance bounding box from edges.

Parameters:

  • object (Sketchup::Group, Sketchup::ComponentInstance)

    A group or a component instance.

  • recursive (Boolean) (defaults to: true)

    Whether to include sub-groups and sub-component instances. All points of a sub-element are transformed to object's transformation and then applied a desired transformation.

  • transformation (Geom::Transformation, nil) (defaults to: nil)

    A coordinate system to transform all the points to before computing. Usually this parameter is the coordinate system object is associated to. Pass nil to compute in object's local coordinates.

Yields:

  • A procedure to determine whether a particular edge, sub-group, or a sub-component instance, should be considered a part of the operation.

Yield Parameters:

  • entity (Sketchup::Drawingelement)

Yield Returns:

  • (Boolean)

    Pass true to consider an entity a part of the operation; pass false to ignore the entity.

Returns:

  • (Geom::BoundingBox)

Since:

  • 3.5.0

.get_bounding_box_from_faces(object, recursive = true, transformation = nil) {|entity| ... } ⇒ Geom::BoundingBox

Note:

This function was revised in version 3.5.0.

Get group/component instance bounding box from faces.

Parameters:

  • object (Sketchup::Group, Sketchup::ComponentInstance)

    A group or a component instance.

  • recursive (Boolean) (defaults to: true)

    Whether to include sub-groups and sub-component instances. All points of a sub-element are transformed to object's transformation and then applied a desired transformation.

  • transformation (Geom::Transformation, nil) (defaults to: nil)

    A coordinate system to transform all the points to before computing. Usually this parameter is the coordinate system object is associated to. Pass nil to compute in object's local coordinates.

Yields:

  • A procedure to determine whether a particular face, sub-group, or a sub-component instance, should be considered a part of the operation.

Yield Parameters:

  • entity (Sketchup::Drawingelement)

Yield Returns:

  • (Boolean)

    Pass true to consider an entity a part of the operation; pass false to ignore the entity.

Returns:

  • (Geom::BoundingBox)

Since:

  • 3.3.0

.get_construction(object, recursive = true, transformation = nil) {|entity| ... } ⇒ Array<Geom::Point3d>

Note:

This function was revised in version 3.5.0.

Get group/component instance construction point and line positions.

Parameters:

  • object (Sketchup::Group, Sketchup::ComponentInstance)

    A group or a component instance.

  • recursive (Boolean) (defaults to: true)

    Whether to include sub-groups and sub-component instances. All points of a sub-element are transformed to object's transformation and then applied a desired transformation.

  • transformation (Geom::Transformation, nil) (defaults to: nil)

    A coordinate system to transform all the points to before computing. Usually this parameter is the coordinate system object is associated to. Pass nil to compute in object's local coordinates.

Yields:

  • A procedure to determine whether a particular construction point, construction line, sub-group, or a sub-component instance, should be considered a part of the operation.

Yield Parameters:

  • entity (Sketchup::Drawingelement)

Yield Returns:

  • (Boolean)

    Pass true to consider an entity a part of the operation; pass false to ignore the entity.

Returns:

  • (Array<Geom::Point3d>)

    An array of points.

Since:

  • 3.3.0

.get_definition(object) ⇒ Sketchup::ComponentDefinition

Get group/component instance definition.

Parameters:

  • object (Sketchup::Group, Sketchup::ComponentInstance)

    A group or a component instance.

Returns:

  • (Sketchup::ComponentDefinition)

Since:

  • 3.3.0

.get_edges(object, recursive = true, transformation = nil) {|entity| ... } ⇒ Array<Array<Geom::Point3d>>

Note:

This function was revised in version 3.5.0.

Get group/component instance edges.

Parameters:

  • object (Sketchup::Group, Sketchup::ComponentInstance)

    A group or a component instance.

  • recursive (Boolean) (defaults to: true)

    Whether to include sub-groups and sub-component instances. All points of a sub-element are transformed to object's transformation and then applied a desired transformation.

  • transformation (Geom::Transformation, nil) (defaults to: nil)

    A coordinate system to transform all the points to before computing. Usually this parameter is the coordinate system object is associated to. Pass nil to compute in object's local coordinates.

Yields:

  • A procedure to determine whether a particular edge, sub-group, or a sub-component instance, should be considered a part of the operation.

Yield Parameters:

  • entity (Sketchup::Drawingelement)

Yield Returns:

  • (Boolean)

    Pass true to consider an entity a part of the operation; pass false to ignore the entity.

Returns:

  • (Array<Array<Geom::Point3d>>)

    An array of edges. Each edge represents an array of two points.

Since:

  • 3.3.0

.get_entities(object) ⇒ Sketchup::Entities

Get group/component instance entities.

Parameters:

  • object (Sketchup::Group, Sketchup::ComponentInstance)

    A group or a component instance.

Returns:

  • (Sketchup::Entities)

Since:

  • 3.3.0

.get_faces(object, recursive = true, transformation = nil) {|entity| ... } ⇒ Array<Array<Geom::Point3d>>

Note:

This function was revised in version 3.5.0.

Get group/component instance faces.

Parameters:

  • object (Sketchup::Group, Sketchup::ComponentInstance)

    A group or a component instance.

  • recursive (Boolean) (defaults to: true)

    Whether to include sub-groups and sub-component instances. All points of a sub-element are transformed to object's transformation and then applied a desired transformation.

  • transformation (Geom::Transformation, nil) (defaults to: nil)

    A coordinate system to transform all the points to before computing. Usually this parameter is the coordinate system object is associated to. Pass nil to compute in object's local coordinates.

Yields:

  • A procedure to determine whether a particular face, sub-group, or a sub-component instance, should be considered a part of the operation.

Yield Parameters:

  • entity (Sketchup::Drawingelement)

Yield Returns:

  • (Boolean)

    Pass true to consider an entity a part of the operation; pass false to ignore the entity.

Returns:

  • (Array<Array<Geom::Point3d>>)

    An array of faces. Each face represents an array of points.

Since:

  • 3.3.0

.get_polygons_from_faces(object, recursive = true, transformation = nil) {|entity| ... } ⇒ Array<Array<Geom::Point3d>>

Note:

This function was revised in version 3.5.0.

Get group/component instance face triplets.

Parameters:

  • object (Sketchup::Group, Sketchup::ComponentInstance)

    A group or a component instance.

  • recursive (Boolean) (defaults to: true)

    Whether to include sub-groups and sub-component instances. All points of a sub-element are transformed to object's transformation and then applied a desired transformation.

  • transformation (Geom::Transformation, nil) (defaults to: nil)

    A coordinate system to transform all the points to before computing. Usually this parameter is the coordinate system object is associated to. Pass nil to compute in object's local coordinates.

Yields:

  • A procedure to determine whether a particular face, sub-group, or a sub-component instance, should be considered a part of the operation.

Yield Parameters:

  • entity (Sketchup::Drawingelement)

Yield Returns:

  • (Boolean)

    Pass true to consider an entity a part of the operation; pass false to ignore the entity.

Returns:

  • (Array<Array<Geom::Point3d>>)

    An array of polygons. Each polygon represents an array of three points - a triplet.

Since:

  • 3.3.0

.get_triangular_mesh(object, recursive = true, transformation = nil) {|entity| ... } ⇒ Geom::PolygonMesh

Note:

This function was revised in version 3.5.0.

Get group/component instance triangular mesh.

Parameters:

  • object (Sketchup::Group, Sketchup::ComponentInstance)

    A group or a component instance.

  • recursive (Boolean) (defaults to: true)

    Whether to include sub-groups and sub-component instances. All points of a sub-element are transformed to object's transformation and then applied a desired transformation.

  • transformation (Geom::Transformation, nil) (defaults to: nil)

    A coordinate system to transform all the points to before computing. Usually this parameter is the coordinate system object is associated to. Pass nil to compute in object's local coordinates.

Yields:

  • A procedure to determine whether a particular face, sub-group, or a sub-component instance, should be considered a part of the operation.

Yield Parameters:

  • entity (Sketchup::Drawingelement)

Yield Returns:

  • (Boolean)

    Pass true to consider an entity a part of the operation; pass false to ignore the entity.

Returns:

  • (Geom::PolygonMesh)

    Everything merged into one mesh.

Since:

  • 3.3.0

.get_triangular_meshes(object, recursive = true, transformation = nil) {|entity| ... } ⇒ Array<Geom::PolygonMesh>

Note:

This function was revised in version 3.5.0.

Get group/component instance triangular mesh collections. Each sub-group, sub-component, a collection of connected faces is reserved its own mesh.

Parameters:

  • object (Sketchup::Group, Sketchup::ComponentInstance)

    A group or a component instance.

  • recursive (Boolean) (defaults to: true)

    Whether to include sub-groups and sub-component instances. All points of a sub-element are transformed to object's transformation and then applied a desired transformation.

  • transformation (Geom::Transformation, nil) (defaults to: nil)

    A coordinate system to transform all the points to before computing. Usually this parameter is the coordinate system object is associated to. Pass nil to compute in object's local coordinates.

Yields:

  • A procedure to determine whether a particular face, sub-group, or a sub-component instance, should be considered a part of the operation.

Yield Parameters:

  • entity (Sketchup::Drawingelement)

Yield Returns:

  • (Boolean)

    Pass true to consider an entity a part of the operation; pass false to ignore the entity.

Returns:

  • (Array<Geom::PolygonMesh>)

    An array of meshes.

Since:

  • 3.3.0

.get_vertices_from_edges(object, recursive = true, transformation = nil) {|entity| ... } ⇒ Array<Geom::Point3d>

Note:

This function was revised in version 3.5.0.

Get group/component instance edge vertices.

Parameters:

  • object (Sketchup::Group, Sketchup::ComponentInstance)

    A group or a component instance.

  • recursive (Boolean) (defaults to: true)

    Whether to include sub-groups and sub-component instances. All points of a sub-element are transformed to object's transformation and then applied a desired transformation.

  • transformation (Geom::Transformation, nil) (defaults to: nil)

    A coordinate system to transform all the points to before computing. Usually this parameter is the coordinate system object is associated to. Pass nil to compute in object's local coordinates.

Yields:

  • A procedure to determine whether a particular edge, sub-group, or a sub-component instance, should be considered a part of the operation.

Yield Parameters:

  • entity (Sketchup::Drawingelement)

Yield Returns:

  • (Boolean)

    Pass true to consider an entity a part of the operation; pass false to ignore the entity.

Returns:

  • (Array<Geom::Point3d>)

    An array of points.

Since:

  • 3.3.0

.get_vertices_from_faces(object, recursive = true, transformation = nil) {|entity| ... } ⇒ Array<Geom::Point3d>

Note:

This function was revised in version 3.5.0.

Get group/component instance face vertices.

Parameters:

  • object (Sketchup::Group, Sketchup::ComponentInstance)

    A group or a component instance.

  • recursive (Boolean) (defaults to: true)

    Whether to include sub-groups and sub-component instances. All points of a sub-element are transformed to object's transformation and then applied a desired transformation.

  • transformation (Geom::Transformation, nil) (defaults to: nil)

    A coordinate system to transform all the points to before computing. Usually this parameter is the coordinate system object is associated to. Pass nil to compute in object's local coordinates.

Yields:

  • A procedure to determine whether a particular face, sub-group, or a sub-component instance, should be considered a part of the operation.

Yield Parameters:

  • entity (Sketchup::Drawingelement)

Yield Returns:

  • (Boolean)

    Pass true to consider an entity a part of the operation; pass false to ignore the entity.

Returns:

  • (Array<Geom::Point3d>)

    An array of points.

Since:

  • 3.3.0

.get_vertices_from_faces2(object, recursive = true, transformation = nil) {|entity| ... } ⇒ Array<Array<Geom::Point3d>>

Note:

This function was revised in version 3.5.0.

Get group/component instance face vertices collections.

Parameters:

  • object (Sketchup::Group, Sketchup::ComponentInstance)

    A group or a component instance.

  • recursive (Boolean) (defaults to: true)

    Whether to include sub-groups and sub-component instances. All points of a sub-element are transformed to object's transformation and then applied a desired transformation.

  • transformation (Geom::Transformation, nil) (defaults to: nil)

    A coordinate system to transform all the points to before computing. Usually this parameter is the coordinate system object is associated to. Pass nil to compute in object's local coordinates.

Yields:

  • A procedure to determine whether a particular face, sub-group, or a sub-component instance, should be considered a part of the operation.

Yield Parameters:

  • entity (Sketchup::Drawingelement)

Yield Returns:

  • (Boolean)

    Pass true to consider an entity a part of the operation; pass false to ignore the entity.

Returns:

  • (Array<Array<Geom::Point3d>>)

    An array of point collections from every included sub-group/sub-component instance. Each point collection represents an array of points.

Since:

  • 3.3.0