How to enumerate component instances of a component definition?

components
definition

#1

Hi All!

We are having difficulty with obtaining geometry from ComponentInstances through the C API in SketchUp SDK 2016. We can query all the component definitions in the Model, but:

  • There are component definitions with 0 instances. We’d like to skip these
  • We want to import all the instances of a component definition. We need to enumerate the instances of a definition for this, and fetch the transformation from the component instance.

We saw that there is a new method in the 2017 SDK: SUComponentDefinitionGetInstances

Is there a tricky workaround we fail to see, or it is just not possible in SketchUp SDK 2016? Please help!

Greetings,
Levente


#2

I don’t know if there is any better way than doing this manually by traversing whole model.

  • get all Entities from Model and from every Definition, SUModelGetEntities / SUComponentDefinitionGetEntities
  • get all ComponentInstances from above Entities, SUEntitiesGetInstances
  • get definition from component instance, SUComponentInstanceGetDefinition
  • match it by SUComponentDefinitionToEntity / SUEntityGetID

#3

Thank you! This is exactly how we did it and works fine!

Just a note:
We used SUEntityGetID to distinguish component definitions, because we could not interpret the GUIDs of component definitions. We used .NET C# and PInvoke.


#4

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.