Sketchup C API, SULoopInputRef, SUGeometryInputRef and egdes

Hi all,

Once again, I have a problem which solution is probably very simple but I can’t figure it out…

I want to modify the converter from my firm format to Sketchup that uses the C API so that I can smooth some edges according to some criteria.

The faces are created the following way:

SULoopInputRef skpFaceLoop;

SUPoint3D * faceVtx = new SUPoint3D[nbVertex];
for(ivtx = 0; ivtx < nbVertex; ivtx++)
	int skpVtxIndex = face.ind_sommet[ivtx];
	if(ivtx < 4) // the material input structure only wants 4 vertices to define the texturing
		skpFaceVtxIndices[ivtx] = skpVtxIndex;
	SULoopInputAddVertexIndex(skpFaceLoop, skpVtxIndex);
	faceVtx[ivtx] = objectVtx[skpVtxIndex];
SUGeometryInputAddFace(skpGeomInput, &skpFaceLoop, &skpFaceIndex);

So it works pefectly, creating Sketchup faces with edges… but how do I get those edges when I create my loop or my face ? I saw there were function such as SUGeometryInputEdgeSetSmooth or SULoopInputEdgeSetSmooth but they both require an edge index I do not have (I guess since I want to set all the edges of a face to smooth or none, an edge number should be enough but I am not even sure).

Should I explicitely create them or is there a way to get those edges that are created anyway since I see them in the generated geometry ?

Thanks a lot and have a good day :slight_smile:

Be sure to close the loop (see doc,) then …

… you know that your loop has nbVertex number of edges, so insert an iterator block (prior to calling the SUGeometryInputAddFace function) to set each edge soft and / or smooth for the skpFaceLoop using the block iterator var ivtx (or whatever you will choose to name it,) as the edge indices.

1 Like

It seems to work perfect even though I still don’t know how to access the edges :wink:

Thanks a lot Dan.

Have a good day :slight_smile:

Okay, it is kinda weird, but the SUGeometryInput and SULoopInput objects are virtual helper object types. The actual geometric (or loop) objects have not yet been added into the model database.

These “helper objects” contain the information (added via the various SUGeometryAdd... functions,) that will subsequently be used to really add geometry (drawingelement) objects to the model using the SUEntitiesFill function. (Think of these “helper objects” as types wrapping structs of data.)

So before you’ve really added the geometry to the model’s entities collection, you can only access the data via indices. In the case of the data to later be used to create the real edges, their indices will correspond to the indices-1 of the vertices in the order each vertex item were added to the data.
(Ie, the vertex 0 is the start point of the loop, vertex 1 is the end point of the edge 0, and so on. The start vertex must be added again lastly to close the loop and serve as the endpoint of the last edge.)

Once the model’s entities collection actually has been filled with objects you’ve created, you can access these objects directly with the “getter” functions of the SUEntities object.

So, to answer your question (in the case of edges,) it will be the SUEntitiesGetEdges function that will allow access to an array of actual edge objects that have already been added to the model’s entities collection.

Oh OK ! I get it :slight_smile:

Thanks again for taking time to help me and have a good day :slight_smile:

1 Like