sketchucation logo sketchucation
    • Login
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    ⚠️ Important | Libfredo 15.6b introduces important bugfixes for Fredo's Extensions Update

    Trying to get a string

    Scheduled Pinned Locked Moved Developers' Forum
    4 Posts 3 Posters 2.7k Views 3 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.
    • W Offline
      WEB
      last edited by

      In a Ruby script, I would like to set a variable equal to the user's input from the keyboard with no inputbox or dialog slowing things down. It's easy as can be in Ruby: myVariable = gets. Darned if I can figure out how to do it in SketchUp Ruby.

      I'm an absolute newb at this, so I'd appreciate any help you can give.

      1 Reply Last reply Reply Quote 0
      • fredo6F Offline
        fredo6
        last edited by

        @web said:

        In a Ruby script, I would like to set a variable equal to the user's input from the keyboard with no inputbox or dialog slowing things down. It's easy as can be in Ruby: myVariable = gets. Darned if I can figure out how to do it in SketchUp Ruby.

        I'm an absolute newb at this, so I'd appreciate any help you can give.

        I am afraid that you have to use a dialog box. gets does not work in Sketchup Ruby.

        There are several methods:

        1. Use the UI.inputbox method. This is short to code (a few lines).

        2. Use a WebDialog or HTMLDialog, much longer to code, but you have full freedom on formatting.

        3. If you develop an interactive "Tool" (i.e. class Sketchup::Tool) and you need a numeric input, you can use the VCB input (method UserText())

        Fredo

        1 Reply Last reply Reply Quote 0
        • W Offline
          WEB
          last edited by

          Thank you. That explains why I couldn't figure out how to do it. On to Plan B!

          1 Reply Last reply Reply Quote 0
          • Dan RathbunD Offline
            Dan Rathbun
            last edited by

            @web said:

            That explains why I couldn't figure out how to do it.

            The real reason is because standard IO has been redirected to SketchUp's Ruby Console.

            I'm not here much anymore.

            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