How to use SU8 plugins in SU2016?

Hi!

I have been gone for a while, and everything has changed :slightly_smiling:

I have tried to copy one of my plugins from SU8 to SU2016, but nothing happens?

In SU8 it was like this:
D:\Program Files\Google\Google SketchUp 8\Plugins\my_plugin_loader.rb
D:\Program Files\Google\Google SketchUp 8\Plugins\my_plugin\main.rb

but in SU2016 there is no plugin-folder? Do you to install it somehow?

Several important things have changed since SU8.

First, user plugins are no longer installed in Program Files folders. They are installed in User Data folders. But due to the next points I won’t tell you where. :smiling_imp:

Second, part way through the SU8 lifetime, a new way to install extensions was added to the Preferences panel. In addition, the Extension Warehouse and sketchUcation plugin store matured significantly, allowing you to download and install extensions directly. These three ways are now the supported way to instal extensions, not by copying the Ruby files.

Third, as of SU 2014, the version of Ruby used by SketchUp for plugins changed. This was a major upgrade, and many old plugins broke. If you simply copy old plugins from SU8 to SU2016 a significant fraction of them will fail, potentially causing SketchUp to crash on launch.

So, the strongly recommended practice is to obtain new copies of the extensions and plugins you need and to install them via the Preferences panel, Extension Warehouse, or SketchUcation plugin store systems.

As was said - always get the latest version of Plugins - they might have been rewritten to suit newer SketchUp methods and Ruby-version…
Then install the RBZ using SketchUp’s: Preferences > Extensions > Install Extension… button to put it into the correct place, automatically, without recourse to a manual botch…

Failing that… in the newer versions of SketchUp the Plugins folder got moved into the user’s AppData file path, so there are now no issues with security-permissions etc…
Your v2016 Plugins folder path is something like:

C:\Users\UserName\AppData\Roaming\SketchUp\SketchUp 2016\SketchUp\Plugins

Or use this snippet pasted into the Ruby Console +enter to actually open the folder itself…

UI.openURL("file:///#{Sketchup.find_support_file('Plugins')}")

Thanks to both of you.

it worked to copy to
UI.openURL("file:///#{Sketchup.find_support_file('Plugins')}")

It shows up in Window->Preferences->Extensions.

And the tool-launch icon shows up… but the plugin itself dont work. But it can be fixed I hope :slightly_smiling:

Any error-messages in the Ruby Console when you try to use it ?
It all suggests that it’s incompatible with the newer SketchUp’s Ruby/syntax - it’s less ‘forgiving’…
Have you not found a newer version of its RBZ from say the EW or SketchUcation PluginStore ??

no, because its a plugin made by me.

and yes it gives som error-messages in Ruby Console. Eg: Error: #<NameError: uninitialized constant ...

Right now Im trying to figure out how to make a simple plugin with an toolbar icon… back to scratch

If you provide the full error we might be able to provide some help.

Thank you!

Actually the plugin is useless but it my hope is to continue to develop it. It uses the webdialog. Do you know if the SU16 webdialog is able to send hashes? In 2012 it couldn’t as far as I remembered.

I’m not sure what you mean by “sending hashes”. Sending from and to where?

As an example you might want to count the numbers of bicycles and send to a server.

n_bikes = 7 # integer-var webdialog.call_to("su_to_server", n_bikes)

on the server you will have a script with a js function:

function su_to_server(n_bikes){ //do something}

As far as I know this could be done with the standard webdialog back in 2012.

The question is if it can send a var like this in SU2016

bike_hash = {red_bikes: 2, blue_bikes: 3, yellow_bikes: 7}

But I will try to experiment a little with that…

No version support that our of the box - converting Hash to a JSON object when calling from Ruby to JS. But it’s perfectly doable.

In SU2014+ you get some help from the fact that the StdLib is shipped. so you can just require 'json' and use .to_json on your hash. On older versions you just have to craft the JSON yourself.

I always use some boilerplate wrapper on top of the webdialog class. I make my own sub-class and add a function that takes a JS function name as first argument and then a set of arbitrary arguments which I convert to a JS string which in turn call .execute_script.

SKUI does this: https://github.com/thomthom/SKUI

I also pass JSON back in callbacks and use the StdLib to interpret the JSON string Ruby receives.

Been meaning to do a blog article on this. And a GitHub snippet.

1 Like

wow amazing! - looks very interesting!

Do you remember that the Aerilius made a WebDialogX? I have made som experiments with that…