I’m new to coding in Ruby for sketch up and have a whole number of questions! Still, I used to do some coding before and currently understand most of coding aspects.
Is it possible to create an interface within SketchUp just using Ruby or do I have to use WebDialog/HtmlDialog? I need to make buttons/tables/ect.
I tried the following code, but it just created a new WebDialog:
wd = UI::WebDialog.new "Point Checker"
wd.execute_script("alert('Hello from Web Dialog')");
It seens like it didn’t implement wd.execute_script(“alert(‘Hello from Web Dialog’)”);
It’s really hard to learn about Ruby and Java Script cooperation in detail, as far as I can’t find any simple step by step explanation of that. I’ve found some written tutorials and they worked for me. I could establish this Ruby/Java Script relation, but the code was more complicated and I don’t quite understand, how it really worked. There are some completely different examples and no really good explanation to the code on the Internet. I’m reading Automatic SketchUp. It’s a fantastic book! However, the code shown in the book is a way different from what really worked in my programme! This simple “wd.execute_script(“alert(‘Hello from Web Dialog’)”);” returns nothing. How do you guys learn this stuff? There no video tutorials or books. This Ruby/JS relation to me is like a rare science. There are so many aspects of it, and so few keys to use. Anyway, thank you, all, folks, who promote this knowledge to people!
(You can also set the document before you show the dialog, but it actually loads when you show it in that case.)
Also the semicolon is misplaced. Ruby does not need semicolons at the end of lines.
wd.execute_script("alert('Hello from Web Dialog');")
However, it focuses on using third party library to speed up development. If you are brand new to Ruby and JS, it might not be ideal to dive into a third party framework as well. But just posting a link here for future reference.
As @john_mcclenahan mentions, there is UI.inputbox - it’s not pretty. But it gives you basic user input. I can be a good place to start if you are learning. Allowing you to focus on one thing at a time.