Quick access snippet library

As you dive deeper into SU, the hidden gem (or Ruby…) really is the documented, free automation library. It gives an enormous potential to automate otherwise boresome or impossible tasks. And now that AI can generate well functioning SU snippets, the automation is even more accessible.

BUT ! Once you have your snipped, or soon-to-be extension, today you need to copy it as a .rb file to a directory, restart sketcup, find it in the menu “Extensions”, and for changes, restart again. This is fine for proper extensions but for snippets that may even be for single use, it gets tiring.

SO here the free idea: give the user a menu with a tree-like strukture. Ability to organise snippets into categories, subcategories, then paste the snippet into a syntax-sensitive editor (giving you proper highlighting), maybe even ability to add metatags etc. Make it able to import / export snippet libraries.

And the final clue: add a shortcut to SU called “execute snippet” (or “macro”). Exactly in the way VBA works for MS Office. Without doing a proper signed add-in, you can add 10 lines of code and do amazing things.

I don’t see this compete with proper extensions, free or for-pay, as the advanced trigonometry won’t be there. But for things like "tag all objects with x,y dimensions = 100x200 with tag ‘test’ " there just isn’t an extension.

EDIT: Became aware of the “Eneroth Script Runner”, but this is not really making snippets an integrated part of SU in a smart way. Although it is better than nothing.

No. Not only.
You can use the built in Ruby Console

Or:
*Have you seen these?
https://sketchucation.com/pluginstore?pln=as_rubyeditor
https://sketchucation.com/pluginstore?pln=ae_Console

1 Like

I made two extensions to work together that sound close to what you’re looking for. One is Forum Notes. It runs in Edge and has right click options specifically for Links and Code Snippets in the SketchUp Forum. If you right click a code snippet copy icon in the forum you can save the code as a code snippet.

See bottom entry of right click menu:

The saved code snippets, links, and notes are available via a dropdown with a copy button for each, so they are easy to copy and paste into the Ruby Console.

I don’t quite have it hooked-up to the other extension, SketchUp Notebook. But it displays notes and notebooks. Here’s a Code Snippets Notebook loaded:

The Notebook can be used, standalone, for code snippets. There’s no copy button on the SU extension side yet. But that would be straight forward to add.

I don’t know if there’s a way to send code to the Ruby Console via an extension. But maybe. Otherwise, copy n paste.

This extension is on my list to update and publish to the Extension Warehouse.

1 Like