Example of Compiled Extension with SWIG and CMake
-
Sounds like there was enough interest in compiled extensions at Basecamp that I whipped up this small example. We have found the recipe of CMake + SWIG to be very useful in making cross-platform extensions (or any C++ project). I have only tested this example on Windows, I may have to update it for Mac, let me know if you have any problems with it. A great idea floated around at Basecamp was to wrap the C++ SDK for file access with Ruby, that way developers could write Ruby scripts to access skp files from within SketchUp or at the command line. I would suggest CMake + SWIG as a route to do that. As a final note, if you really don't like the generated interfaces you can always wrap the generated wrapper code from SWIG with your own pure Ruby to your heart's content.
The attached file is really a zip file, rename the file extension to .zip and extract.
Hope this helps,
Dan
-
This sounds interesting.
@unknownuser said:
A great idea floated around at Basecamp was to wrap the C++ SDK for file access with Ruby, that way developers could write Ruby scripts to access skp files from within SketchUp or at the command line.
That is very interesting!
-
-
I started a project to wrap the SDK for Ruby at:
http://code.google.com/p/ruby-sketchup-sdk/
I am just getting started now and focusing only on Windows but hopefully this could be extended pretty quickly. Let me know if you are interested in helping/using.
Dan
-
Hey Dan, it was great to meet you at Basecamp. I do think this is an interesting project. I'm of no use in helping out with project, but I am interested in using it
Chris
-
I'm also interested in this project - though atm mostly of curiosity without any exact specific usage, yes.
-
@thomthom said:
I'm also interested in this project - though atm mostly of curiosity without any exact specific usage, yes.
I think you could, for example, write a .skp converter using ruby that worked on a .skp file instead of needing to run in SketchUp.
Batch conversions, thumbnail extraction, add/remove/modify geometry, explode, etc.
-
I imagine AdamB said at some point he'd managed to access setter methods for layers and materials via the SDK. Even get layer materials. Now that would be useful!
-
After working with the SDK for a little while I don't think it can be wrapped as quickly as I first thought. I have to get back to work on my real tasks so the SDK wrap project will have to wait for a while. But I did make another example using SWIG with directors to show how to pass Ruby objects into C++ code. We are looking into this to implement Ruby observers for events that happen in our own C++ code.
Hope this helps,
Dan
-
(you can upload .zip files here)
-
Hi, has anyone tried this on Mac OSX (10.6)?
For SWIG I did the standard: ./configure, make, make install.
but when i try to CMake your examples above i get this:swig error : Unrecognized option -initname
swig error : Unrecognized option Examplefor -initname "Example" in CMakeList.txt
also if i remove that it doesn't get better.
I tried SWIG versions 2.0.0 and 1.3.40 with no luck,
and I have ruby 1.8.7 (so should be no problems here...).Please help,
Thank you.
Advertisement