Skip to content

Instantly share code, notes, and snippets.

@folkertdev
Created May 24, 2016 18:36
Show Gist options
  • Save folkertdev/915f0694b9ce6b07fdecceeb3f5bbdf0 to your computer and use it in GitHub Desktop.
Save folkertdev/915f0694b9ce6b07fdecceeb3f5bbdf0 to your computer and use it in GitHub Desktop.
C++ iterator to Python tuple
// from the Blender Freestyle code
static PyObject *Stroke_viewedges_begin(BPy_Stroke *self)
{
PyObject *output = PyTuple_New(self->s->viewedges_size());
std::vector<ViewEdge*>::iterator ve_it = self->s->viewedges_begin(), ve_end = self->s->viewedges_end();
for (unsigned int i = 0; ve_it != ve_end; ++ve_it, ++i) {
PyTuple_SET_ITEM(output, i, BPy_ViewEdge_from_ViewEdge(*(*ve_it)));
}
return output;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment