Create group
-
hello,
I create an entitie with a plugin but i don't arrive create a group with each point of my entitie...
require 'sketchup.rb' def add_etiquette # Get "handles" to our model and the Entities collection it contains. model = Sketchup.active_model entities = model.entities # Create a series of "points", each a 3-item array containing x, y, and z. pt1 = [0, 0, 0] pt2 = [30, 0, 0] pt3 = [30, 0, 17] pt4 = [0, 0, 17] # Call methods on the Entities collection to draw stuff. new_face = entities.add_face pt1, pt2, pt3, pt4 ##here i want create a group of "new_face"(in sketchup it's a selection right click and make group). ##How do in ruby? end #Menu if (not file_loaded?("zEtiquette_config.rb")) tool_menu = UI.menu "Tools" tool_menu.add_item("Create zone item") { add_etiquette } $VSX = Vsx.new file_loaded("zEtiquette_config.rb") end
-
Create the group before you create the face.
# Get "handles" to our model and the Entities collection it contains. model = Sketchup.active_model entities = model.entities # Create a series of "points", each a 3-item array containing x, y, and z. pt1 = [0, 0, 0] pt2 = [30, 0, 0] pt3 = [30, 0, 17] pt4 = [0, 0, 17] # Create group to contain entities group = entities.add_group # Call methods on the Group's entitites collection to draw stuff. new_face = group.entities.add_face(pt1, pt2, pt3, pt4)
It's a bit different from when you model in SU where you first draw your entities, then group. When you write ruby scripts, it's best to create the group first, then add the entities inside that group.
-
something like this should do it:
group = entities.add_group group.entities.add_face(pt1,pt2,pt3,pt4)
Basically all your doing is creating a group then adding your face to the list of entities contained within the group. Because of this you can remove the
entities.add_face
in your original code. -
oh, ok.... it's simple. thx guys
Advertisement