sketchucation logo sketchucation
    • Login
    🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    Selection of item created

    Scheduled Pinned Locked Moved Plugins
    3 Posts 2 Posters 544 Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • P Offline
      Pauline01
      last edited by

      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
      
      
      
      1 Reply Last reply Reply Quote 0
      • thomthomT Offline
        thomthom
        last edited by

        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.

        Thomas Thomassen — SketchUp Monkey & Coding addict
        List of my plugins and link to the CookieWare fund

        1 Reply Last reply Reply Quote 0
        • P Offline
          Pauline01
          last edited by

          oh! thx

          1 Reply Last reply Reply Quote 0
          • 1 / 1
          • First post
            Last post
          Buy SketchPlus
          Buy SUbD
          Buy WrapR
          Buy eBook
          Buy Modelur
          Buy Vertex Tools
          Buy SketchCuisine
          Buy FormFonts

          Advertisement