[Example]An example to help you how to write SketchUp Ruby code with HtmlDialog

Several problems ...
  1. It belongs in the Developers > Ruby API category. Since recategorized, thanks.

  2. Try to follow convention and prefix your thread with “[code]” or “[Example]” as others have done in the proper category. Since done, thanks.

  3. The local reference dialog that your example uses is only persistent at the top level, which is in Object.
    Coders in a shared environment need to code within their own namespaces. (Defining things in the global ObjectSpace makes them percolate into everyone else’s objects, including API objects, modules and classes.)
    Your example code would usually be implemented within a method, and using a local reference would go out of scope when the method ends and the dialog would close.
    See topic thread: HtmlDialog closing by itself

  4. The first 2 statements in your action callback block serve no purpose …

  javaScript="var inpObj1 = document.getElementById('id1').value; var inpObj2 = document.getElementById('id2').value; var inpObj3 = document.getElementById('id3').value;"
  dialog.execute_script(javaScript)

… these were executed on the JavaScript side prior to the Ruby side action callback being called.

1 Like