Selection of item created
-
Re hello,
You help me to create a groupe of entities, but i need to select automaticly this group // object after the creation because i want add an attribute with dictionnary system.
In the code, i want select my object after the line "#i want select the item created to configure an attribute #???".
Thx.
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 group = entities.add_group group.entities.add_face(pt1,pt2,pt3,pt4) #i want select the item created to configure an attribute #??? #define an adress for the object in a dictionnary prompt = ["Name_zone"] val = Sketchup.active_model.selection[0].get_attribute("MyDico", "Name_zone") default = [val] result = UI.inputbox prompt, default, "Enter the Zone Name" adrresult = result[0].to_s adr = Sketchup.active_model.selection[0].set_attribute("MyDico", "Name_zone", adrresult.to_s) UI.messagebox ("@ ; " + adr.to_s + " saved") 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
-
You need to actually select it?
You already have an reference to the group:
# Call methods on the Entities collection to draw stuff. # new_face = entities.add_face pt1, pt2, pt3, pt4 group = entities.add_group
the variable group is now referring to the group you created.
#i want select the item created to configure an attribute #??? group.set_attribute('yourDictionary', 'yourProperty', 'yourValue')
This will set the attribute without having to specifically select it.
-
oh! thx
Advertisement