(Please post your Ruby questions in the Ruby API subcategory.)
What single quotation marks ?
… ie, we cannot read minds.
If Ruby, then you must use a double-quoted string in order to do interpolation.
I again point you to the Ruby Core primer on String literals …
Unless you are targeting versions older than 2017 I would recomend switching to the newer UI:HtmlDialog.
When testing your HTML dialog, just right-click on your dialog window, and choose “Show DevTools” …
That isn’t good for developing an extension. It’s only useful for playing around (learning) with one liners or small snippets that do concise tasks.
As said, it has been known to introduce problems. It itself is a html dialog, that sends commands and script text to Ruby, which evaluates it, and would then send command to your html dialog.
So … from Ruby …
There IS a quirk with JS’s
innerHTML= and Ruby strings. There cannot be any newline characters at the end of any of the HTML text in the Ruby string. If there are, the JS
innerHTML= method can fail (perhaps silently.)
Since you do not have control over the Ruby strings sent to your dialog, (ie the “Ruby Code Editor” has all the control,) you will not be able to overcome that barrier, if it occurs.
In my extensions, when I load the HTML from a file, (and I have this problem) … I use a
:chomp option to remove newline characters. IE … (a snippet from my code) …
# Load the HTML for each listing line striping out newline characters.
# within CEF fails if the HTML text contains embedded Ruby newlines:
list_line = File.readlines(filepath, chomp: true).join('')
If you insist working in this way you’ll continue to run into problems. I don’t have any more time to deal with silly issues.
My last advice to you is to ditch that “Code Editor”, and get a real editor application like:
Then code like a real programmer codes in files, and load your files as an extension loads when SketchUp starts.
As in any language, the natural learning process begins by repeating the words of others to try to say what you want to say; wich is particulary difficult when it comes to programming in Ruby+JS. I borrowed a WebDialog old example and I have managed to display my arrays in my html window. At the moment I don’t have enough level to assimilate all the information from your posts, although they are there for when they can help in this learning process.
As I said, I’m a novice Ruby person who started to program in Ruby, using the Skup Oficial Code Editor, 2 months ago, with the intention of programing, basically working on object attributes and exchanging information with excel, where I usually work. I didn’t expect the problems with the Skup 'Oficial’Code Editor or the recomenation to use JS and Html to display information in a proper way, which implies added problems, mostly unsolved from years ago. This silly issues don’t occur when you have worked properly to offer people a way to program. So they are the unexpected Sketchup Developers silly issues that any novice has to deal with. I will be very grateful to get all these unexpected information in advance, or your understanding when I keep saying or doing things in a wrong way, just because I didn’t get that information. Following your recomendation, I sincerely don’t know how I should program from other editors and run the program over my model. Thanks in advance. I will understand if you leave the forum. They are opened questions.
Here are the steps. I recommend VS Code.
Also (contrary to Dan’s advice), I find Ruby Console + to be quite useful. You still need to use the built in ruby console to get accurate error info. That is what Dan mentioned. I find Ruby Console +, to be really handy when doing quick testing. You can use the built in tool to easily get a reference to an object in the model.
1. The is no such word as “Skup”.
2. There is no “Official” SketchUp Code Editor.
Instead, there are several 3rd party extensions, that are implemented in a web html dialog.
Unfortunately, the reality is that it is not Trimble’s responsibility to teach any kind of programming. Only to document their APIs.
I personally have spent many days and hours to compile lists of resources for novice SketchUp Ruby coders …
The list has links to free downloadable books on Ruby programming, as well as links to online blog posts and tutorials, many are SketchUp specific.
A forum is not really an adequate place to teach programming.
I am sorry that there is no way that we can “pour” the coding knowledge into novice brains.
Any person’s ability to absorb and apply new coding knowledge will depend upon their current foundation of the person’s programming knowledge.
This is why Steve asked you right away in the other topic on web dialogs …
… but you never really gave a good answer. So we didn’t have any good idea of your ability level.
So this basically makes me feel as though I’ve wasted two days of my time, when it comes to specifically helping you.
It is no one else’s responsibility but your own, to seek out and learn basic programming knowledge, so that when you ask questions, you are able to understand the answers.
I am not leaving. I am just not going to waste any more time giving advice that will not be used.
Hopefully other readers may find it useful.
**1. There is no such word as “Skup”
I used Skup as an abbreviation of Sketchup.
**2. There is no “ Official ” SketchUp Code Editor.
You are right, they are no “Official” SketchUp Code editors, but they are recommended extensions that do what they should do, considering what you can learn from https://ruby.sketchup.com/ I thought they were the better way to start programming with Ruby. I must confess that I’m lost when I read Ruby’s articles outside of the SketchUp environment, or I find any sample Ruby code. I have verified that there are commands not working in any of the Sketchup Code Editors, without any reference in https://ruby.sketchup.com/, so I avoid those commands and those websites. Nevertheless, I think it’s better to use extensions to run the code easily and facilitate my learning process.
I think it is offensive to use the adjective “silly” to refer to someone’s issue. That will keep beginners away from this forum. Nor are they such silly problems when they need such complex solutions. Therefore, it is understandable that these issues, not well resolved, appear repeatedly for many years in this forum. So, if something has to be silly, it should be that nobody notices it or nobody improves it.
Trimble’s responsibility? Offer easy ways to do easy things. I appreciate the capability to create dictionaries with your own attributes, create lists, … but it’s dificult to understand why you can’t show or work with all this information in an appropriate way. You shouldn’t need to leave ruby to do all these kinds of things. By doing this, you are exposing your code to errors, incompatibilities with browsers, … Thus, I have to settle for using the dynamic attribute dialog box, with no possibility to group my information, nor use drop-down windows. And, this is not an attack, this is an attempt to make a constructive contribution. I love Sketchup too.
I hope that you will not be offended, it was never my intention.