From 52e289ee3bfdeb063a3099c0a805a0294044af47 Mon Sep 17 00:00:00 2001 From: Tamito Kajiyama Date: Sat, 14 Mar 2009 13:11:34 +0000 Subject: [PATCH] Fixed StrokeVertex::setPoint() to accept a Blender Vector object as the argument. Now this method accepts 2D coordinates in the following three forms: a) Python list of 2 real numbers: setPoint([x, y]) b) Blender Vector of 2 elements: setPoint(Vector(x, y)) c) 2 real numbers: setPoint(x, y) [The log of Revision 19283 had a wrong message...] --- .../Interface0D/CurvePoint/BPy_StrokeVertex.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/source/blender/freestyle/intern/python/Interface0D/CurvePoint/BPy_StrokeVertex.cpp b/source/blender/freestyle/intern/python/Interface0D/CurvePoint/BPy_StrokeVertex.cpp index 1e2d34c2767..a62296a37d7 100644 --- a/source/blender/freestyle/intern/python/Interface0D/CurvePoint/BPy_StrokeVertex.cpp +++ b/source/blender/freestyle/intern/python/Interface0D/CurvePoint/BPy_StrokeVertex.cpp @@ -235,11 +235,27 @@ PyObject *StrokeVertex_setPoint( BPy_StrokeVertex *self , PyObject *args) { } if( PyList_Check(obj1) && !obj2 ){ + if ( PyList_Size(obj1) != 2 ) { + cout << "Error: StrokeVertex::setPoint() accepts a list of 2 elements (" + << PyList_Size(obj1) << " found)" << endl; + Py_RETURN_NONE; + } Vec2f v( PyFloat_AsDouble( PyList_GetItem(obj1, 0) ), PyFloat_AsDouble( PyList_GetItem(obj1, 1) ) ); self->sv->setPoint( v ); + } else if ( VectorObject_Check(obj1) && !obj2) { + if ( ((VectorObject *)obj1)->size != 2 ) { + cout << "Error: StrokeVertex::setPoint() accepts a vector of 2 elements (" + << ((VectorObject *)obj1)->size << " found)" << endl; + Py_RETURN_NONE; + } + Vec2f *v = Vec2f_ptr_from_Vector( obj1 ); + self->sv->setPoint( *v ); + delete v; } else if( obj1 && obj2 ){ self->sv->setPoint( PyFloat_AsDouble(obj1), PyFloat_AsDouble(obj2) ); + } else { + cout << "Error: StrokeVertex::setPoint(): unknown argument type" << endl; } Py_RETURN_NONE;