Have you downloaded the book on Writing Ruby Extensions in C from my Ruby Resources book list?
It’s at the bottom of the Downloadable GENERIC list:
There are a couple of examples in the the official repo, but they do not yet have any thing of substance other than accepting a string value from Ruby:
I would say instead look through the “Samples” folder of the C SDK.
First of all, you do not need to prefix your C side identifier with "SUEX_"
. That is something that the Extensibility Team did that means “SketchUp EXample”.
It is customary to use a unique author or company prefix. On the Ruby side this translates to a top level namespace module identifier. Your extension should be wrapped in a submodule of this namespace module. Then you can mimic this on the C side. (Perhaps even the C++ section could use the same namespace identifiers?)
Okay, as to getting a C side reference to SUEntitiesRef
, you cannot pass this as an entity because it is not an Sketchup::Entity
subclass.
SketchUp’s collections are C++ collections and are exposed to the Ruby API as direct subclasses of Object
.
If you will be using the new SUEntityFromRuby
C function, then your Ruby side EntitiesObserver#onElementModified
observer callback will only be able to pass the 1 entity subclass object. (Meaning that an integer count is unnecessary.)
So once you have the SUEntityRef
from the new SUEntityFromRuby
C function, you can ask it what parent collection it is a member of with SUEntityGetParentEntities
.