A Group class contains methods for manipulating groups of entities.
Groups in SketchUp are very similar to Components, except that there is no
instancing of groups. That means that you always will have one and only one
of each of your groups. (In the actual implementation, SketchUp keeps track
of groups as a special kind of Component that combines properties of
definitions and instances, which is why you will see deprecated methods
like Group.make_unique, and the class of observer you attach to Groups are
ComponentInstance observers.)
The add_observer method is used to add a ComponentInstance observer to the group.
Arguments:
Returns:
# Add a group to the model. group = Sketchup.active_model.entities.add_group group.entities.add_line([0,0,0],[100,100,100]) status = group.add_observer observer
The copy method is used to create a new Group object that is a copy of the group.
Returns:
# Add a group to the model. group = Sketchup.active_model.entities.add_group group.entities.add_line([0,0,0],[100,100,100]) group2 = group.copy
The description method is used to retrieve the description for the group.
Returns:
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 group to the entities in the model group = entities.add_group # Get the entities within the group entities2 = group.entities # Add a face to within the group face = entities2.add_face pts group.description = "This is a Group with a 2d Face" description = group.description
The description= method is used to set the description for the group.
Arguments:
Returns:
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 group to the entities in the model group = entities.add_group # Get the entities within the group entities2 = group.entities # Add a face to within the group face = entities2.add_face pts group.description = "This is a Group with a 2d Face" description = group.description if (description) UI.messagebox description else UI.messagebox "Failure" end
The entities method is used to retrieve a collection of entities in the group.
Returns:
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 group to the entities in the model group = entities.add_group # Get the entities within the group entities2 = group.entities # Add a face to within the group face = entities2.add_face pts entities = group.entities if (entities) UI.messagebox entities else UI.messagebox "Failure" end
The explode method is used to explode the group into individual entities.
Returns:
# Add a group to the model. group = Sketchup.active_model.entities.add_group group.entities.add_line([0,0,0],[100,100,100]) UI.messagebox "Grouped" status = group.explode if (status) UI.messagebox "Exploded Group" else UI.messagebox "Failure" end
The local_bounds method returns the BoundingBox object that defines the size of the group in an untransformed state. Useful for determining the original width, height, and depth of a group regardless of its current position or scale. For components, you can get a similar result by checking my_instance.definition.bounds.
Returns:
# Add a group to the model. group = Sketchup.active_model.entities.add_group group.entities.add_line([0,0,0],[100,100,100]) transformation = Geom::Transformation.new([100,0,0]) # Note that local_bounds_1 and local_bounds_2 will be identical, since # they both find the bounding box in group's untransformed state. local_bounds_1 = group.local_bounds group.transform! transformation local_bounds_2 = group.local_bounds
The locked= method is used to lock a group.
Returns:
# Add a group to the model. group = Sketchup.active_model.entities.add_group group.entities.add_line([0,0,0],[100,100,100]) status = group.locked = true
The locked? method is used to determine if a group is locked.
Returns:
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 group to the entities in the model group = entities.add_group status = group.locked? UI.messagebox status
The make_unique method is a deprecated method used to force a group to have
a unique definition.
Copying a group using the copy tool in SketchUp will create copies of the
group that share a common definition until an instance is edited manually or
this method is used. If multiple copies are made, all copies share a
definition until all copies are edited manually, or all copies have this
method used on them. This method ensures that the group uses a unique
definition entry in the drawing database.
Returns:
# Add a group to the model. group = Sketchup.active_model.entities.add_group group.entities.add_line([0,0,0],[100,100,100]) group.make_unique
The move! method is used to apply a transformation to the group.
This method is the same as the transform! method except that it does not
record the move in an undo operation. This method is useful for
transparently moving things during an animation.
Arguments:
Returns:
point = Geom::Point3d.new 500,500,500 t = Geom::Transformation.new point 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 group to the entities in the model group = entities.add_group # Get the entities within the group entities2 = group.entities # Add a face to within the group face = entities2.add_face pts UI.messagebox "Group before Move" group = group.move! t if (group) UI.messagebox "Group after move" UI.messagebox group else UI.messagebox "Failure" end
The name method is used to retrieve the name of the group.
Returns:
# Add a group to the model. group = Sketchup.active_model.entities.add_group group.entities.add_line([0,0,0],[100,100,100]) group.name = "A Line" name = group.name
The name= method is used to set the description for the group.
Arguments:
Returns:
# Add a group to the model. group = Sketchup.active_model.entities.add_group group.entities.add_line([0,0,0],[100,100,100]) group.name = "A Line" name = group.name
The remove_observer method is used to remove a ComponentInstance observer from the group.
Arguments:
Returns:
group = Sketchup.active_model.entities[0]
if group != nil
if group.typename == "Group"
status = group.remove_observer observer
end
endThe to_component method is used to convert the group to a component instance.
Arguments:
Returns:
# Add a group to the model. group = Sketchup.active_model.entities.add_group group.entities.add_line([0,0,0],[100,100,100]) # change the group to a component instance group.to_component
The transform! method is used to apply a transformation to a group.
Arguments:
Returns:
point = Geom::Point3d.new 500,500,500 t = Geom::Transformation.new point 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 group to the entities in the model group = entities.add_group # Get the entities within the group entities2 = group.entities # Add a face to within the group face = entities2.add_face pts UI.messagebox "Group before Move" group = group.transform! t if (group) UI.messagebox "Group after move" UI.messagebox group else UI.messagebox "Failure" end
The transformation method is used to retrieve the transformation for the group.
Returns:
# Add a group to the model. group = Sketchup.active_model.entities.add_group group.entities.add_line([0,0,0],[100,100,100]) trans = group.transformation
The transformation= method is used to set the transformation for the group.
Arguments:
Returns:
# Add a group to the model. group = Sketchup.active_model.entities.add_group group.entities.add_line([0,0,0],[100,100,100]) new_transform = Geom::Transformation.new([100,0,0]) group.transformation = new_transform