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_groupthe 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
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better đź’—
Register LoginAdvertisement