Loading components from a File

For the record I did via a very verbose PM critique of another plugin in DEC of 2017. (But it likely got lost within too much info at one time.)

It is actually a simple example, but I’d encourage you to instead use JSON.


Going between Ruby Hash, JSON strings and SketchUp attribute dictionaries …

And the most comprehensive of my posts on going from Ruby hashes and arrays → JS Objects using JSON strings …


Example of Ruby array to JS array:

So basically … from the Ruby-side …

my_ary = [[1,2,3],[4,5,6],[7,8,9]]
html_dlg.execute_script("Data = JSON.parse('#{my_ary.to_json}');")

… and afterward Data is a JS reference for a nested JS array.
(Note you may need to declare Data as a global var set to null first.)

1 Like