Trying to get a string
-
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.
-
@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:
-
Use the
UI.inputbox
method. This is short to code (a few lines). -
Use a WebDialog or HTMLDialog, much longer to code, but you have full freedom on formatting.
-
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
-
-
Thank you. That explains why I couldn't figure out how to do it. On to Plan B!
-
@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.
Advertisement