SketchUp Bridge Tutorial
A bidirectional communication system between JavaScript and the Ruby environment
SketchUp Bridge Tutorial

The SketchUp Bridge library provides an intuitive and asynchronous API for message passing between SketchUp's Ruby environment and dialogs. This is a tutorial for existing and prospective developers about how to use this library.

API Overview

Ruby methods:

    Creates a Bridge instance for a UI::WebDialog or UI::HtmlDialog.
  • Bridge.decorate(dialog)
    Alternatively adds the Bridge methods to a UI::WebDialog or UI::HtmlDialog.
  • Bridge#on(callbackname) { |deferred, *arguments| }
    Registers a callback on the Bridge.
  • Bridge#call(js_function_name, *arguments)
    Invokes a JavaScript function with multiple arguments.
  • Bridge#get(js_function_name, *arguments).then{ |result| }
    Invokes a JavaScript function and returns a promise that will be resolved with the JavaScript function's return value.

JavaScript functions:

  •, ...arguments)
    Invokes a Ruby callback with multiple arguments.
  • Bridge.get(rbCallbackName, ...arguments).then(function (result) { })
    Invokes a Ruby callback and returns a promise that will be resolved with the callback's return value.
  • Bridge.puts(stringOrObject)
    Shorthand to print a string/object to the Ruby console.
  • Bridge.error(errorObject)
    Shorthand to print an error to the Ruby console.


Introductory forum topic for discussion
Github project
Minimal sample extension template

52 utenti
32.65 KB
SketchUp Bridge Tutorial (3.0.0); Gennaio 29, 2019
Number of Views: 
Compatibilità SO: