SU development workflow / environment

I’ve been learning Ruby, and SU scripting, and I need to level up my development setup. I’ve found some great resources so far (SU dev pages, SU github, thomthom’s sites, dan’s megathread). I haven’t yet set up the debugging, testing, etc, but I’m particularly interested in testing scripts live in SU. I’ve been using Console+ and Ruby Code Editor to play with scripts – but I’d much prefer to do my editing in VSCode. Ideally I can work on a script in VSCode, and then activate the script in SketchUp with a keyboard shortcut.

Maybe… save the script in a special “working directory” (or use a proxy loading script), and then have a SU tool which activates any script located in that special folder (e.g. tools / Run Current Script), or with a special filename. Thoughts? I’m sure I’m missing something obvious!

I’m compiling what I learn here. I will soon dive into learning minitest and its SU integration, testup.

1 Like

You need to download the debugger DLL and place it in SketchUp’s binary folder.

I’ve already created lists of links here in this category. (You are reinventing the wheel.)

If you write your code as extensions, then you can switch them ON and OFF via the Extension Manager interface.


Each of your extensions will need to be separated from one another, so this is a closer example …

module NN_MyOwnUniqueNamespace
  module HelloWorld

    # Use instance variables inside modules instead of global variables.
    @my_variable = 'Hi there! :)'

    def self.hello_world
      puts @my_variable
    end

    unless defined?(@loaded)
      menu = UI.menu( 'Plugins' )
      menu.add_item( 'Hello World' ) { self.hello_world }
      @loaded = true
    end

  end # extension submodule
end # top level namespace

You do not need to require "sketchup.rb" unless your code uses what that file defines.
(Also, since SU2014 it is loaded by SketchUp before any of the extensions in the “Plugins” folder ever get evaluated.)

Many of us recommend using a local module @loaded var to determine whether to load UI elements, rather than the slow and clunky file_loaded() and file_loaded?() methods defined in "sketchup.rb".
(String comparison is slow in Ruby, and those methods use a global shared array in which simple file names might clash. Long absolute pathnames are going to slow the startup cycle.)

Anyway, there is nothing in that file, that you cannot code better and faster, private alternatives to.

1 Like

Thanks Dan! Sounds like I need to play more with the tutorials at hand, before asking specialized questions. I’m not sure whether it will do what I’m looking for, but I’ll find out.

And I had actually found and used your mega-wiki-thread, and forgot to credit it in my post (edited for posterity). My own little “wiki” that I linked is primarily to help me remember things that I learn, and it’s really just a repo of markdown files.

1 Like

Ah okay like a checklist.

Well I got tired of researching the same bits of information multiple times, so I try to log everything now. It’s something between bookmarking and journaling, editable from any device (on mobile I use GitJournal). I figure markdown will be flexible enough to convert it to a wiki format or something in the future – Wiki.JS or Hugo, for example.

Anyways, I’ll play with the SU tutorials and your templates, etc , and hopefully return with some more worthwhile queries. And hopefully I’ll encounter more information about this @loaded technique.

1 Like

I typically define a method in my extensions that I can call to reload all their Ruby files. Other use a script that detects file changes and reloads the file right away. There is no one right way.

1 Like