How to add C++ plugins to SketchUp editor

Ah yes, that information is here:

Also, your plugin code needs to be wrapped within it’s own Ruby namespace module. Many developers use a toplevel author or company module, and nest each plugin within it’s own sub-module.

There is no such “readme.txt” file. If the plugin is a tool (or has a tool,) then the menu item could be on the Tools menu. Or if it is a specific drawing tool, then it could be on the Draw menu. If it is an importer or export it is usually put on the File menu. If it has to do with the camera or animation, it’ll usually be on the Camera menu. … etc.
If it is more complex, or doesn’t fit on any other menu, then put it on the Extensions (aka Plugins) menu.

And you have not said what kind of plugin it is, so I cannot even guess.

I would be happy to have the existing “Hello World” or “skp_to_html” samples having the additional parts they need so that they can be loaded into SU 2017. I have been unable to get even these simple apps to load and/or appear.

have you tried building and running licensed_ruby_extension?

it has all the bits…

john

1 Like

(1) if you mean “skp_to_xml”, this example is not a SketchUp Ruby extension !

It is a pure C/C++ dynamic linked library that implements an exported interface pointer that SketchUp will respond to. (See the bottom of the “skp_to_xml/skp2xml.cpp” file.)
EDIT(Add): … and the “headers/SketchUpAPI/import_export/modelexporterplugin.h” file,
which has extensive inline commentary that will explain a lot.

These kinds of exporter libraries (as Thomas said above,) are just copied into the SketchUp binary’s “Exporters” sub-directory (on Windows.)
When SketchUp starts up, it will enumerate all the exporter libraries in this directory.
These also usually require a dedicated installer of their own, as they install in the %ProgramFiles% path which requires administrative privileges.


(2) With regard to “Hello World” and all the other Ruby C extension example CODE at the GitHub Repo, it is a repository of example SOURCE CODE not a final compiled build of these extensions. It would do no good to supply a RBZ with this repository. (The RBZs would be out of place.)
Secondly, a RBZ file is nothing more that a renamed ZIP archive, that has the finalized compiled files organized in a sub-directory, per that instructions given at:

… whose code follows the instructions for the Ruby SketchupExtension class given in the API docs:

The only fully compiled and RBZ wrapped example, is the Create LayOut example.
It properly resides in the SketchUp Team’s Store, of the Extension Warehouse (because it does not belong with the uncompiled example source code.):

Thanks John, that is exactly what I needed!

For the clarification of anyone else who finds themselves here looking for answers here are some details. If you are running a licensed version of SketchUp follow these steps (otherwise do steps 1-4 and then jump down to 1a below):

  1. In the SDK zip file, look for the folder samples\licensed_ruby_extension.
  2. At this level it contains the .sln file, which you will want to build (use VS2015 if building for SketchUp 2017)
  3. Building creates the subfolder: samples\licensed_ruby_extension\RubyExtension\su_licensedrubyextension\bin64
  4. In that folder is licensed_ruby_extension.so, which is a really just a renamed .dll file

To install this app:

    1. At the folder level samples\licensed_ruby_extension\RubyExtension, create a zip that contains both the su_licensedrubyextension.rb file and the su_licensedrubyextension subfolder
    1. Rename the resulting zip file to su_licensedrubyextension.rbz
    1. In SketchUp, navigate to the menu item Windows > Extension Manager and click the red “Install Extension” button
    1. Navigate to the .rbz file you created and select it, then close the Extension Manger
    1. Under the menu “Extensions” you should now see “Licensed Extension”, which you can test launch

To run it under debug:

10: First make sure SketchUp is running, and the plugin is installed
11. In Visual Studio, with the plugin project open, go to the menu item Debug > Attach to Process
12: Select “SketchUp.exe” from the list of running programs
13. Add break points to the code
14. In Sketchup, select the menu option Extensions > Licensed Extension, your break points should be hit

Note: if (like me) you are running the trial version of this program:

1a: Edit samples\licensed_ruby_extension\RubyExtension\su_licensedrubyextension\loader.rb
2a: Comment out lines 31 and 34, to remove the requirement to be licensed to load
3a: Go back to step 5 above, and try again. (You may need to uninstall the previous attempt with the Extension Manager)
4a: Make sure to put a break point in the CheckLicense() function in licensed_ruby_extension.cpp

Best of luck fellow developers!

Dear friends,
all above looks like the SO files should be functional. What my problem is:
I have programmed several Ruby C++ extensions compiled as DLL/SO files in Windows.
I started in 2014 with 23bit and tried some more with 64bit since February 2017.
All went well peacefully with Sketchup 2014 32bit and 2015 and 2016 64bit.
This might make me blind somewhat because now I have been stopped dead:
With Sketchup 2017 my Ruby code refuses to load SO files.

A code like this:

Sketchup.require ‘C:/Users/<…>/AppData/Roaming/SketchUp/SketchUp 2017/SketchUp/Plugins/3E_SO_Test_UI/SO_Test_DllMfc.SO’ #I tried DLL and to remove the file extension as well…

results with

File load error (C:/Users/<…>/AppData/Roaming/SketchUp/SketchUp 2017/SketchUp/Plugins/3E_SO_Test_UI/SO_Test_DllMfc.SO): Could not find included file ‘C:/Users/<…>/AppData/Roaming/SketchUp/SketchUp 2017/SketchUp/Plugins/3E_SO_Test_UI/SO_Test_DllMfc.dll’
false

There is no rescue exception so no more clue what is wrong.
Nevertheless it looks like the file content does this. When I just replace the file with just “…/something_empty.rb” without touching one more letter in the path, the file is loaded OK.

Further notes:
All my projects are based on the

download.

My environment is VisualStudio2010.

This test I perforned with the “Hello world”.
I compiled it in x64 platform with libraries titled “2.0” and “2.2”. I double checked this in the project configuration.
When I used “2.2” then the SO file ceased to work in Sketchup <2017 but there was still a relevant error message like “improper version of something”.
In Sketchup 2017 both “2.0” and “2.2” compilations results in the same “Could not find included file”.

Please where to look next, I am short of ideas?

Now I have good news: It works (for now…:-))!
What it was:
Sketchup.require does not support DLL’s anymore. I can live with this but you appreciate the message ‘Could not find included file’ yourself…
I had to use the “Ruby kernel” require.
AND(!!!) the SO file must be the “2.2” compilation. This I omitted but the spilling my guts above helped some and I sniffed and performed this last move…

I would be glad if I might help you someday.

This was between 2017 and 2016?

Did you use to have Ruby C Extensions created with .dll file extension? The convention in Ruby is that they are named .so.

Yes, exactly.
Concerning file extension: I set the SO file extension directly in the project properties.
Struggling through all this, however, I tried (almost) everything:-)
What was the crucial point:
I found one buried print on my desk titled “Developer Preview Release notes Sketchup 2017” that somebody handed to me half a year ago or so. There it read “…any compiled C extensions will need to be rebuild”. I noted this before but I mistakenly associated this need between 32bit and 64bit edition (which is also true, isn’t it?) and not between 2016 and above.

I believe it was the core Ruby Kernel#require that dropped support for the DLL file extension.
Sketchup::require itself only handles the RBS and RBE encrypted files, and passes all other filetypes on to Kernel#require.