C++ observer?

This is going to be an issue for users. They already complain when autosave kicks in on it’s set interval.
I cannot see users being fond of having your exporter kick in after every change. But this is just my opinion.

There no longer is a SketchUp C++ API. All vestiges of the old one was removed (I think for the initial 2019 release.) Only the C++ importer and exporter interfaces remain, AFAIK.

Yes. Ruby itself is implemented in C. You can get a reference to the open model and create Ruby observer objects on the C side, by making Ruby C calls. (Also for SU2019.2+ there is a C function exported by the application in “application.h” of the C API, … meant currently for read only use. It provides access to the “live” active model reference.)

Thomas has created a project for a SketchUp Ruby C extension at GitHub.

You’ll need the same Ruby version header files for the SketchUp version your exporter targets.
SketchUp version 2021 uses Ruby 2.7.1, (SU2019 and SU2020 use Ruby v2.5.5, SU2017 & 2018 use Ruby v2.2.4; SU2015 & SU2016 use Ruby v2.0.0.)

If you download the C SDK it may contain other examples. It also has the Ruby Core C header files for the current SketchUp version(s) which are 2019.2 and 2020.0.1, (ie Ruby ver 2.5.5-p157.)


Also I’ve posted a link to a free PDF book on writing Ruby C extensions which can help you a lot. It has a glossary of the most used Ruby Core C functions. It’s link is at the bottom of the Books section …


There are quite a few topic threads on accessing “live” models via C here, probably in the C SDK subcategory, but perhaps in the Ruby API subcategory. If you search from this (parent) category the results will be from all 3 categories.


:bulb: