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.
getsdoes not work in Sketchup Ruby.There are several methods:
-
Use the
UI.inputboxmethod. 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.
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