To solve a problem in one of my applications I need to explode a (nested) component instance in the C API.
As there is no explode method in the C API (I checked the binaries again today, and the commented out SUGroupExplode method is not exported from the DLL), I’m trying to partially simulate explode functionality.
One of the things I’m trying is to downcast the SUComponentInstanceRef to an SUGroupRef using SUGroupFromComponentInstance
Add this instance to the model entities as test, this works as expected, so the instance is correctly loaded.
Downcast the instance to a group using SUGroupFromComponentInstance, which results in an empty SUGroupRef (null pointer). According to the documentation this indicates that the instance cannot be downcast to a group.
Does any one know why this could be? Or more specifically does anyone know what the prerequisites are for downcasting a SUComponentInstanceRef to an SUGroupRef in the C API. I cannot seem to find any documentaion on this.
I’ve tested this with both a nested and a non-nested component. The nested one looks like this:
What I’m trying to do here, is add the downcasted group to my model entities, like a poor mans explode. I might try to iterate recursively over ell entities in the component and see if I can add each entity to my model entities. That is more (tedious) work though.
Thanks for the suggestion. I am considering this approach, but prefer a solution where I don’t need to launch SketchUp for model generation or manipulation.
My programs mostly work quite well with the C API. Things sometimes get difficult for edge cases.
Over the years I have developed a set of libraries to work with SketchUp from within .NET Windows desktop applications. The investment in these libraries is huge and my users are very much used to the current workflow. If I really need to I will make the switch, probably only for certain functionality.
Switching to a scenario where I need to launch SketchUp will also incur a performance hit my users will not be happy with.
Unfortunately the latest release of the C API (2026.0.429) still doesn’t provide a way to explode groups. The above mentioned function is still commented out in group.h, and the method is also still not exported from the DLL.