sketchucation logo sketchucation
    • Login
    ℹ️ GoFundMe | Our friend Gus Robatto needs some help in a challenging time Learn More

    Novice Ruby Questions - Regarding dropdown windows

    Scheduled Pinned Locked Moved Newbie Forum
    sketchup
    3 Posts 2 Posters 226 Views
    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.
    • H Offline
      haebooty
      last edited by

      Hello. I am new to ruby and sketchup and have been trying to learn. I had a question regarding drop down windows. I was looking at an example I found from T. Burch at ruby library depot called dropdown.rb, which was very helpful. In my experimenting I have been unable to figure out how could you make it so the dropdown windows are in say slot 2-4 instead of 1-3.

      Here is his example:

      require 'sketchup.rb'
      var1 = "Last Choice"
      inputbox1 = %w[Choice1 Choice2 Choice3 Choice4].join("|") 
      inputbox2 = %w[Option1 Option2 Option3 Option4].join("|")  
      inputbox3 = %w[Selection#1 Selection#2 Selection#3].join("|") 
       
      array_of_dropdowns = [inputbox1, inputbox2, inputbox3]    # An array of arrays
      
      if !@val1 then @val1 = "Choice1" end       # Assigning instance variables, they are remembered each 
      if !@val2 then @val2 = "Option2" end       # time the script is run in a session.  
      if !@val3 then @val3 = "Selection#3" end   # These values must match one of the array values!!!
      if !@val4 then @val4 = 4 end               # Otherwise, no value is displayed as a default choice.
      
      prompts = ["Choose your Choice", "Opt your Option", "Select your Selection   ", "Enter a Number"]
      
      values = [@val1, @val2, @val3, @val4]   
      
      @val1, @val2, @val3, @val4 = inputbox prompts,values, array_of_dropdowns, "Multi-Drop Down Example"
      
      print "variable @val1 is ", @val1, "\n" 
      print "variable @val2 is ", @val2, "\n" 
      print "variable @val3 is ", @val3, "\n" 
      print "variable @val4 is ", @val4, "\n" 
      

      Is it possible to make it so, enter number is at the top and then is followed by the three dropdown menus: choice, option, and selection? Any help would be greatly appreciated. Thank you in advance.

      1 Reply Last reply Reply Quote 0
      • K Offline
        kyyu
        last edited by

        Did you figure it out? You just need to 1)put a blank filler in there to shift the original options down. And 2)rearrange your default values.

        1. array_of_dropdowns = ["", inputbox1, inputbox2, inputbox3]
        2. values = [@val4, @val1, @val2, @val3]

        -Kwok

        1 Reply Last reply Reply Quote 0
        • H Offline
          haebooty
          last edited by

          Yes I did thank you 😄

          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