How to make multiple selected face into their own group?


model = Sketchup.active_model
entities = model.active_entities
selection = Sketchup.active_model.selection

faces =

selection.each do |e|
faces << e if e.is_a? Sketchup::Face
end

faces.each do |face|
face.add_group ???

end

Is there a way to make multiple selected face into a series of groups?

Please learn how to format your code properly…

This make one group of the selected faces.

model = Sketchup.active_model
entities = model.active_entities
selection = model.selection
faces = selection.grep(Sketchup::Face)
if faces[0]
  group = entities.add_group(faces)
  group.name = "All selected faces"
end

This makes separate groups of each selected face.

model = Sketchup.active_model
entities = model.active_entities
selection = model.selection
faces = selection.grep(Sketchup::Face)
faces.each_with_index{|face, i|
  group = entities.add_group(face)
  group.name = "Face #{i+1}"
}

2 Likes

As said in your other topic …

2 Likes