I need to export each separate object from a sketchup file.
I found and using the function SUModelGetEntities to retrieve all the entities, then for them I execute SUEntitiesGetFaces to retrieve all the faces in the model.
The problem is that if I have for example a cube and a circle, I retrieve 7 faces but I don’t know how two create two separate object.
Should I traverse the model in another way to retrieve the objects?
But if I want to know what are the entities ’ to which belong faces, how can I do?
I need to import them in separate object:
for example a cube has 6 faces and a circle has 1 face,
I’ve tried to export as obj model and I have two meshes (one for cube and one for circle)… I have to do the same in my source code.
Is it clear which is the problem?
You need to clarify what you mean by “object”. As @DanRathbun has pointed out, SketchUp has geometric primitives and isolated collections of them (groups and components) but it has no larger or more structured notion of “object”. So, what does it mean to export an object?
Perhaps what you are looking for is an SDK equivalent to the GUI’s triple-click or context menu Select->all connected and the Ruby API’s #all_connected methods on Edge and Face Entities. These recursively find all the Entities that share geometry with the starting Entity and anything it touches. They will gather in everything that is not spatially isolated from the argument or in a different Entities collection (group or component). This is as close as SketchUp has to a notion of non-primitive “object”.
Alas, so far as I can tell (@DanRathbun please correct me if I’m wrong) the C/C++ SDK has no such pre-written method. If you want such, you are expected to write it yourself using the sorts of functions Dan listed to follow the links between touching entities.
So it looks like you’d get the outer loop for a face: SUFaceGetOuterLoop()
… then get it’s edge uses array: SULoopGetEdgeUses()
… iterate this, checking for partners, and collecting the partner EdgeUses’s face: SUEdgeUseGetFace()
… repeat until you have collected arrays of all the connected edges and faces for a single “spatial object”.
Then process this collected set of edge and face references for export, as whatever kind of object it needs to be in the destination Object Model.
But since, you never said what format “your side” is, we can only go on guessing. We do not know if “your side” has groups or components, or only “mesh objects”.
In SketchUp’s world, if primitives are not part of a group or component instance, then they are primitive geometry that belong to the model’s entities collection. They will however interact and “stick to each other” and share vertices, etc.
The APIs do have a Polygon Mesh helper (virtual) class, which is often used to facilitate import and export. The samples show using this.
Have you looked at the samples for export to, and import from XML ?