Hi All - I’ve been programming with the SU Ruby API for years, very comfortable with that framework. In order to have the flexibility of providing and managing licenses with a new plugin, I’m dipping my toes into the C++ SDK. I have experience programming in C++, but my achilles heel always seems to be getting a project setup, so I hope you’ll bear with me.
I want to test in my Pro installation of Sketchup 2023, so the only changes I made to ThomThom’s files so far is to change references to SketchuUp 2017 to SketchUp 2023 in Hello World.vcxproj:
Thank you for any help you can give! I’m a newb at the ruby integration, so instructions on what to do with this example, once it’s running are also welcome .
When I still tinkered around with stuff like this, a .so file was a shared library, not an executable. Is this a different kind of .so file specific to SUP or VS or even C?
Edit. Never mind, I’ve been away from that world too long. Disregard.
with some additional googling, it looks like .NET didn’t install with Visual Studio. I uninstalled and re-installed Visual Studio 2019 making sure to install the .NET package this time
When opening the project, select “Open a project or solution”, then open the file: “SketchUp Ruby C Extension Examples.sln”
I’m still figuring out the rest, but the example file now opens Sketchup
There are also a bunch of examples available with the SDK download
SketchUp 2020, 2021, 2022, and 2023.0 for Windows were built using Visual Studio 2019, and so plugins should be built with the Platform Toolset set to Visual Studio 2019 (v142).
This seems to indicate a newer version of VS could be used as long as the toolset is set properly for the SketchUp versions targeted by the extension being compiled.
Also, the README for the ruby-c-extension-examples repository explains about a couple of compiler switches that coders should take note of.
There are specific instructions to setting up a SketchUp extension project for VSCode which may also work (in a similar fashion) in full blown VS.
True. In this case the project compiles a so file meant to be loaded into a Ruby process using Ruby’s global require method.
Such libraries must have a proper C entry point function whose name begins with the prefix Init_ and finishes with the same name as the compiled so file.
For this "SUEX_HelloWorld.so" library file, it’s entry point function must be named: "Init_SUEX_HelloWorld", viz :
.
Ruby itself is implemented in C.
More information about coding Ruby in C can be found in the Writing Extensions in C ebook by Dave Thomas:
.
… and the SketchUp C API has received some functions to pass data back and forth from Ruby ↔ C. See:
The documentation does not say so, but I would guess that points and vectors could be passed back and forth as arrays of numerics (doubles on the C side).