On the incorrect loading of the official "htmldialog-examples"

Hello everyone! I’m from China and I’m glad to be here. I’ve only recently come into contact with ruby plug-ins. It’s not long before I get into touch with them. So the following questions may seem childish to you. Okay, please forgive me. Thank you!

The problem lies in:
I downloaded an “htmldialog-examples” template from github, but I found that I placed it directly under the “Plugin” folder and opened SketchUp and found that the plug-in could not be loaded. So I had to write a script to load it, but it failed in the end. Can you help me solve it?

Here’s my load script, but I don’t know what the problem is.

HtmlDialog Examples.rb (358 Bytes)

Hello you all,
its very difficult to me to start with html dialogs. I found some examples but I was not able to install them. Especially the above mentioned htmldialog-examples on github. I would be glad someone could explain me how to install them on skechup. Please step by step.
I downloaded all the files as .zip folder. Where do I have to unpack the files? resp. how to start in sketchuppro.
Thank you
spb

  • SketchUp loads a Ruby file at startup if it is in the Plugins folder (C:\Users\<user>\Roaming\SketchUp\SketchUp 2018\Plugins or Library/Application Support/SketchUp 2015/SketchUp/Plugins). The content of the Ruby file is evaluated immediately, so code that is not wrapped in a method and registered in the UI runs at startup.
    Knowing this, you probably have to copy the contents of the src folder into the Plugins folder.

  • Alternatively you can side-load scripts from any location if their requirements are specified relative to their loader file (not relative to the Plugins folder). This is the case for these htmldialog-examples.

    load "/path/to/downloads/src/tutorial.rb"
    
  • Check also out the sketchup-bridge project, which provides a different, unified approach to communicating between Ruby and the dialog in both directions.
    You can test-drive it with this tutorial extension. If you like it, you can clone the Github project. There is also a sample can be copied into your Plugins folder (before making your own project, rename AuthorName and SampleExtension to your personal namespace).

Did you get any errors?
I currently cannot test your loader script, but possibly the file extension was missing:

# …
ext = SketchupExtension.new(("HtmlDialog Examples",File.join(NAME, "tutorial.rb"))
# …

If it loads without error but the toolbar is not visible, the extension is maybe not yet enabled (in Window → Extension Manager) or the toolbar not enabled (in View → Toolbars).

Hi ZhangjinHeng, actually your problem is the same with SPB’s.
It is not necessary to use a load program.

Putting the .rb example files into the “plug-in” folder is the right step.
However, the “.rb file” should be directly at the “plug-in” folder rather than any folders under “plug-in” such as “examples”.
Then, the extension will load as you re-start trimble or SU.
You can check it under menu “extensions” > “extension manager”

The key problem with Github html examples is that they are 1 step from “complete”.
For example, in the first tutorial “step01.rb”. There are only several methods defined but there are no executive method calls. Therefore, you should add a line to the module:
“show_dialog”
Save it and restart the app again. You will see the html dialog prompts at the app start-up.

I figured this out from Mariocha and Camlaman’s previous topics. I really appreciate their sharing.
https://forums.sketchup.com/t/example-html-dialog-suite/79584

1 Like

The examples were originally written as a tutorial for reading/watching - accompanying a DevCamp presentation.

But I can see the use in making them easier to run. I logged an issue for that: Make the examples easily runnable · Issue #5 · SketchUp/htmldialog-examples · GitHub

3 Likes