I decided to do a topic on setting up NetBeans for SketchUp/Ruby development with debugging.
Steps are similar for Mac and Windows, but where they differ the steps are included for both.
1. Install NetBeans
2. Install Plugins for NetBeans
a. Go to NetBeans Plugins
b. Type ‘Ruby Rails’ in the filter and then download the Plugin.
c. Download 'Path Tools’
d. Install the plugins you just downloaded
- Run NetBeans. Select Tools>Plugins
- Click the Downloaded tab and then click Add Plugins
- Select the files you downloaded including the jar file but not the xml file. (On Mac this is two steps because you can only choose between *.nbm or *.jar, not both)
- Install And restart IDE
e. repeat these steps for the Path Tools plugin you down loaded.
3. Setup code completion, documentation and intellisense.
a. Create a new project > Ruby Application
b. Go to Tools > Options to setup code completion and hints.
c. In your main.rb start coding, create a variable and then verify auto complete is working. In the picture below ‘t’ is a string variable. On the second line after typing the period a list of methods for strings should show.
d. Click the button in the documentation window to locate your ruby stubs.
e. If Path Tools installed correctly press the ‘Explore Path…’ button or navigate to the file location manually.
f. Down load this as a zip and copy the Sketchup folder.
g. Paste the Sketchup folder in the location of your ruby stubs.
h. Verify that SketchUp specific auto complete is working.
4a. Setup SketchUp for debugging (Windows)
a. Download the SURubyDebugger.dll for the version of SketchUp you are using. Paste it in the same folder as your Sketchup.exe.
b. Create a shortcut and edit the target to include the commandline arguments for debugging.
4b. Setup SketchUp for debugging (Mac)
a. Download the SURubyDebugger.dylib for the version of SketchUp you are using.
b. add it into the application package in the frameworks folder.
c. create an application shell script to run SketchUp with debugging arguments. (there might be a better way. I’m not very familiar with Mac.)
5. Debug your project
a. Launch SketchUp for debugging using the shortcut set up in step 4. (On Mac A terminal window is opened and for me it asks for my password. I had to enter this before I could continue.) Sketchup will appear frozen or locked up until the debugger is attached. This is normal it’s simply waiting on the debugger.
b. In NetBeans Attach the Debugger.
c. SketchUp should be frozen until the debugger attaches.
d. Open the rb file to debug, and set several break points. (I’ve noticed sometimes the first breakpoint or two won’t be recognized initially.)
e. Make sure any changes to the file are saved.
f. Load the rb. file from the Ruby console in SketchUp. Running the file from NetBeans will run it in your local Ruby (with errors), and not in Sketchup. This is one of the most important details for new users.
g. When a break point is encountered the code will stop executing and SketchUp will be frozen until it continues. NetBeans does not automatically come to the front.
h. Step through code and watch variable values in NetBeans IDE.
i. When finished hit continue and see results in SketchUp.
6. Deploy your project (Added 7-22-17)
I do my main development in a git repository. I place add debug toolbar button in SU to load the file I’m currently working on. However at some point it’s necessary to copy the files to the plugin directory so all the plugin is up to date. This can be done by creating a batch file to copy the files to correct location. This is especially useful when deploying to many computers on a network.
Here are the steps to access you update script from within Netbeans.
a. Right click anywhere in the empty space of an open file, and select Send To>Configure.
b. Click the Add button then set the script name (‘Update’ in this case), last enter the full path to the batch file in both the script field and the area below it. Make sure it is enclosed in double quotes.
c. When you are ready to update your plugins simply right click in the empty space of any file and select Send To>Update.
Here is the batch script I use. Notice that some of the locations receive scrambled files for security.
echo off echo Copying Files xcopy /y "C:\Users\User\Documents\SourceTree Projects\Building Creator\RBScripts\Building_Creator\lib\*.rb" "C:\Users\User\Documents\SourceTree Projects\Building Creator\RBScripts\Building_Creator\Deployment\" >nul echo Encrypting Files FOR %%I in ("C:\Users\User\Documents\SourceTree Projects\Building Creator\RBScripts\Building_Creator\Deployment\*.rb") DO "C:\Users\User\Documents\SourceTree Projects\Building Creator\RBScripts\Building_Creator\Deployment\Sketchuprubyscramblerwindows.exe" "%%I" >nul 2>nul move /y "C:\Users\User\Documents\SourceTree Projects\Building Creator\RBScripts\Building_Creator\deployment\*.rbs" "C:\Users\User\Documents\SourceTree Projects\Building Creator\RBScripts\Building_Creator\Deployment\encrypted" >nul echo Updating Neil-Home (Unencrypted) xcopy /y "C:\Users\User\Documents\SourceTree Projects\Building Creator\RBScripts\Building_Creator\deployment\*.rb" "%userprofile%\AppData\Roaming\SketchUp\SketchUp 2017\SketchUp\Plugins\Building Creator\" >nul echo Updating NeilCo (Unencrypted) xcopy /y "C:\Users\User\Documents\SourceTree Projects\Building Creator\RBScripts\Building_Creator\deployment\*.rb" "\\NEILCO\Users\Server Computer\AppData\Roaming\SketchUp\SketchUp 2017\SketchUp\Plugins\Building Creator\" >nul echo Updating BCC-Dave (Encrypted) xcopy /y "C:\Users\User\Documents\SourceTree Projects\Building Creator\RBScripts\Building_Creator\deployment\encrypted\*.rbs" "\\BCC-Dave\Users\Dave Burkholder\AppData\Roaming\SketchUp\SketchUp 2017\SketchUp\Plugins\Building Creator\" >nul echo Updating PAINTCOUNTER (Encrypted) xcopy /y "C:\Users\User\Documents\SourceTree Projects\Building Creator\RBScripts\Building_Creator\deployment\encrypted\*.rbs" "\\PAINTCOUNTER\Users\Paint Counter\AppData\Roaming\SketchUp\SketchUp 2017\SketchUp\Plugins\Building Creator\" >nul echo Removing temporary deployment files. del "C:\Users\User\Documents\SourceTree Projects\Building Creator\RBScripts\Building_Creator\deployment\encrypted\*.rbs" >nul del "C:\Users\User\Documents\SourceTree Projects\Building Creator\RBScripts\Building_Creator\deployment\*.rb" >nul
I get an error displayed for any computers that are disconnected from the network.
I hope this helps.