How do I link NetBeans IDE to built in Sketchup Ruby?

After a long lapse, I’m trying to write a new plugin, and amend an old one.

Following an old post I got NetBeans installed some years ago, but with difficulty. And haven’t used it for at least a year or more since.

when I first started NetBeans tonight, it listed three plugin files I’d worked on in the past. But then they disappeared and I can’t find a way to reopen them.

But when I try to start a new project, it says that one of the Ruby versions installed is corrupt or not working - v2.3.7 something.(The other is v1.7x, which is roughly what older versions of SU used). I did as the error message suggested, and went to the NetBeans menu item Tools/Ruby Platform to fix it.

It’s now apparently updated and installed correctly, as
Ruby 2.3.7 (2018-03-28 patchlevel 456) [universal.x86_64-darwin18]

This isn’t the Ruby built in to Sketchup, which it hasn’t located, although SU 2020 is open, with a model loaded, and the Ruby console open too. When I run (from NetBeans) a short piece of test code to create an InputBox in SU, I get the output

/.../main.rb:7:in `<main>': undefined method `feet' for 14:Fixnum (NoMethodError)

which looks to my inexpert eye that it hasn’t understood something that’s common in SU Ruby, but not standard Ruby, how to convert from feet to inches. It is correctly referring to the location of the file I just created.

Any idea how I can point NetBeans to the SU Ruby version?

Or do i have to copy the code from the NetBeans window to the Ruby console to run it?

When I do that, the code runs and opens an InputBox, but dimensions that should be in feet are showing in inches (so what should display as 14’ shows as 168", and so on for other dimensions in the InputBox.)
image

I searched in Finder for ‘Ruby’ and found entries in the Application Support folder for SU2020, within the ~/Library parent folder, in the Sketchup install log (which I can’t find again now!) suggesting Ruby v2.5.5 framework(s) are installed within the SU Application Support files in ~/Library… something.

But there were multiple entries, all looking very similar, so I don’t know which if any of those I found, to try to point NetBeans to use.

Maybe I just need to re-read the old thread, and work it out from scratch again, but if anyone knows of a shortcut to that, I’d be grateful.

NO, they used Ruby v1.8.6-p287 up through SketchUp 2013.

There really isn’t any good reason to have any older Ruby version installed on your system (unless some other application needs it.)

Re, Ruby v2.3.7
SketchUp went from v1.8.6-p287 (SU8 … SU2013)
to v2.0.0-p247 (SU2014 … SU2016),
then to v2.2.4-p230 (SU2017 … SU2018)
then to v2.5.1 patchlevel? (SU2019.0 … SU2019.1)
then to v2.5.5-p157 (SU2019.2 … SU2020 current release)

… so you wouldn’t need v2.3.7 system Ruby installed for testing any SketchUp extensions.

I’d say that this is your “system Ruby” distributed by Apple “out of the box”.

You should be able to install other Ruby versions and switch between them with a Ruby Version Manager. (On Windows I use the uru command line utility.)

Correct. NetBeans doesn’t know the extensions to the core Ruby classes that the SketchUp API has made.

I think you need to load the Ruby API stubs to prevent NetBeans from generating NoMethodErrors, NameErrors, etc.

You also need the debugger to hook an IDE into SketchUp … (but the README is missing an instructions link for NetBeans.)

Dan, thank you so much for your clarifications and corrections of my misunderstandings or ignorance.

I’ll see what I can make of your instructions and either get NetBeans working again, or find an alternative route.

1 Like