# Create Face with GeometryInput Creating Empty Component

**URL:** <https://forums.sketchup.com/t/create-face-with-geometryinput-creating-empty-component/11984>\
**Category:** SketchUp SDK\
**Created:** [June 9, 2015, 2:35pm UTC](https://forums.sketchup.com/t/create-face-with-geometryinput-creating-empty-component/11984 "2015-06-09T14:35:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ecwi232](https://avatars.discourse-cdn.com/v4/letter/e/e47c2d/32.png) [@ecwi232](https://forums.sketchup.com/u/ecwi232)\
**Post date:** [June 9, 2015, 2:35pm UTC](https://forums.sketchup.com/t/create-face-with-geometryinput-creating-empty-component/11984/1 "2015-06-09T14:35:11Z")

</div>

I am looping through getting my points in p0\_x, p0\_y…and so on. Then I push them into my vector of SUPoint3D.

```
    std::vector<SUPoint3D>polygon;    
    SUPoint3D pPoint0 = {p0_x, p0_y, p0_z};
    SUPoint3D pPoint1 = {p1_x, p1_y, p1_z};
    SUPoint3D pPoint2 = {p2_x, p2_y, p2_z};
        
    polygon.push_back(pPoint0);
    polygon.push_back(pPoint1);
    polygon.push_back(pPoint2);  

```

My vector gets filled with about 2000 points.  
Then I go to create my GeometryInputRef and LoopRef.

```
                        SUGeometryInputRef input = SU_INVALID;
			SUGeometryInputCreate(&input);

			long vertex_index_start = 0;
			size_t face_index;

			int count = polygon.size();
			SUPoint3D* points = new SUPoint3D[count];

			for(int c=0; c < count; c++){
				/*double pX = polygon[c].x;
				double pY = polygon[c].y;
				double pZ = polygon[c].z;*/
				points[count - c - 1] = polygon[c];
			}

			//SUGeometryInputSetVertices(input, polygon.size(), &polygon[0]);
			//SUGeometryInputSetVertices(input, count, points);
			//delete [] points;

			SULoopInputRef loop = SU_INVALID;
			SULoopInputCreate(&loop);
			for(size_t i=0; i < count; i++){
				//SUGeometryInputAddVertex(input, &polygon[i]);
				SUGeometryInputAddVertex(input, &points[i]);
				SULoopInputAddVertexIndex(loop, i);
			}
			//SUResult addInnerLoop = SUGeometryInputFaceAddInnerLoop(input, face_index, &loop);
			SUResult addFace = SUGeometryInputAddFace(input, &loop, &face_index);

```

The addInnerLoop result gets an error\_out\_of\_range, but the addFace result is none.  
Then I call:

```
        SUEntitiesRef entities = SU_INVALID;
	SUModelGetEntities(model, &entities);

	SUEntitiesFill(entities, input, true);

```

But it creates an empty model.

---

<div class="post-metadata">

**Author:** ![tt\_su](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/tt_su/32/17_2.png) [@tt\_su](https://forums.sketchup.com/u/tt_su)\
**Post date:** [June 10, 2015, 10:48am UTC](https://forums.sketchup.com/t/create-face-with-geometryinput-creating-empty-component/11984/2 "2015-06-10T10:48:39Z")

</div>

Have you checked the return values of your function calls?

---

<div class="post-metadata">

**Author:** ![jeff\_howe](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/jeff_howe/32/7278_2.png) [@jeff\_howe](https://forums.sketchup.com/u/jeff_howe)\
**Post date:** [June 22, 2015, 3:05pm UTC](https://forums.sketchup.com/t/create-face-with-geometryinput-creating-empty-component/11984/3 "2015-06-22T15:05:18Z")

</div>

The variable face\_index is not valid (it’s uninitialized) at the point of calling  
SUGeometryInputFaceAddInnerLoop(); it’s set on the SUGeometryInputAddFace() call that follows. That’s why you’re getting an error\_out\_of\_range result. You shouldn’t need to call SUGeometryInputFaceAddInnerLoop() with the outer loop anyways.
