I want to output rectangles but for some reason I am unable to - here is the crucial part of the code (The rest is part of an example found in the SDK so I’m sure it’s ok - the code works fine but it always shows a single rectangle when I drop the created model into my browser):
// Create the face
SUFaceRef face[2] = SU_INVALID;
struct SUPoint3D vertices[4] = { { 0, 0, 0 },
{ 100, 100, 0 },
{ 0, 0, 0 },
{ 200, 200, 100 } };
SUFaceCreateSimple(face, vertices, 2);
SUFaceCreateSimple(face+1, vertices+2, 2);
// Add the face to the entities
SUEntitiesAddFaces(entities, 2, face);
Any ideas what’s wrong with the above code - remember I want to add sequentially rectangles defined by 2 points in the 3d space.
I’ve also looked into SUPlane3D but I don’t seem to find any way to use such a structure then with a Section Plane which I obviously don’t need.
I’m really desperate now - even after removing all of the ‘draw’ calls (ie. All the code posted above) I still get a single rectangle. How is that possible?
If they were, they’d might produce a bowtie effect as you have the origin point as 2 of the vertices.
Always check your objects after doing a geometry creation call before using the object later in code. Ie, you are not getting the return value from the create function call and testing it for errors.
Sorry, but you’d have to write your own function. The API call needs 1 point for every vertex of the face, and since rectangles have 4 edges, there must be 4 points passed in the points array, if you are to get a rectangular face.
You are trying to create two faces out of only four vertices. Each face you try to create out of two vertices. Check the return value and you’ll see error codes. (Always check these). You need to provide all the vertices for the face loop - meaning you need at least 3.
NOTE: This function does not merge geometry, which will likely create an invalid SketchUp model. It is recommended to use SUGeometryInput instead which does correctly merge geometry.
The faces it creates doesn’t merge properly. We should probably put some compile time warnings to these functions to make it clearer they are bugged.
Look into SUGeometryInput instead for creating geometry in the C API. It ensures to merge geometry.
What are you doing with the #define there? Calling SUEntitiesFill after each SUGeometryInputSetVertices?
Looks like you are trying to call SUEntitiesFill for each face you are trying to create. (Again after setting only 2 vertices at a time. Note my comment earlier, you need at least 3 points to define a face. And you need 4 points to define a rectangle.)
With SUEntitiesFill you call it once, after you built all your geometry using SUGeometryInputRef.
Make sure you check the return values from your calls. They give you information when you have provided incorrect input. That will give you clues.
Without seeing the whole code I cannot say exactly why you get that message about inserting empty component. But from the snipped it looks like your calls are failing - hence not generating any geometry.
Note that we have examples in the SDK package. Have you looked at those?
That’s not what I meant. The API never allows you to create a face form 2 points. At all times you must provide all the points that makes up the face. If you want a face with four vertices, you must provide four points.