diff options
author | Willian Padovani Germano <wpgermano@gmail.com> | 2005-03-01 05:37:19 +0300 |
---|---|---|
committer | Willian Padovani Germano <wpgermano@gmail.com> | 2005-03-01 05:37:19 +0300 |
commit | 52b84f0e6930ae80e05442d2a88810ae517b586a (patch) | |
tree | 00872d695b7fcf48e21621ba0cd1420683764195 /source/blender | |
parent | 6c62b0d8b7ec9a4513304dd817d7b7a3a5f72f65 (diff) |
BPython:
- Gert de Roost reported an inconsistency between nmesh.getMode and .setMode. Now .setMode() optionally accepts an int value, as returned by getMode().
- Campbell Barton pointed that object.getData(name_only=True) was by mistake returning the obj name, not the obdata name, as it should. Fixed now.
- small doc updates
Thanks both for the reports.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/python/api2_2x/NMesh.c | 53 | ||||
-rw-r--r-- | source/blender/python/api2_2x/Object.c | 2 | ||||
-rw-r--r-- | source/blender/python/api2_2x/doc/NMesh.py | 5 | ||||
-rw-r--r-- | source/blender/python/api2_2x/doc/Window.py | 9 |
4 files changed, 44 insertions, 25 deletions
diff --git a/source/blender/python/api2_2x/NMesh.c b/source/blender/python/api2_2x/NMesh.c index 0bf2aa4b933..ba7729267fa 100644 --- a/source/blender/python/api2_2x/NMesh.c +++ b/source/blender/python/api2_2x/NMesh.c @@ -255,7 +255,7 @@ static char NMesh_getMode_doc[] = "() - get the mode flags of this nmesh as an or'ed int value."; static char NMesh_setMode_doc[] = - "(none to 5 strings) - set the mode flags of this nmesh.\n\ + "(int or none to 5 strings) - set the mode flags of this nmesh.\n\ () - unset all flags."; static char NMesh_getMaxSmoothAngle_doc[] = @@ -1507,30 +1507,41 @@ static PyObject *NMesh_getMode( BPy_NMesh * self ) static PyObject *NMesh_setMode( PyObject * self, PyObject * args ) { BPy_NMesh *nmesh = ( BPy_NMesh * ) self; + PyObject *arg1 = NULL; char *m[5] = { NULL, NULL, NULL, NULL, NULL }; short i, mode = 0; - if( !PyArg_ParseTuple - ( args, "|sssss", &m[0], &m[1], &m[2], &m[3], &m[4] ) ) + if( !PyArg_ParseTuple ( args, "|Ossss", &arg1, &m[1], &m[2], &m[3], &m[4] ) ) return EXPP_ReturnPyObjError( PyExc_AttributeError, - "expected from none to 5 strings as argument(s)" ); - - for( i = 0; i < 5; i++ ) { - if( !m[i] ) - break; - if( strcmp( m[i], "NoVNormalsFlip" ) == 0 ) - mode |= EXPP_NMESH_MODE_NOPUNOFLIP; - else if( strcmp( m[i], "TwoSided" ) == 0 ) - mode |= EXPP_NMESH_MODE_TWOSIDED; - else if( strcmp( m[i], "AutoSmooth" ) == 0 ) - mode |= EXPP_NMESH_MODE_AUTOSMOOTH; - else if( strcmp( m[i], "SubSurf" ) == 0 ) - mode |= EXPP_NMESH_MODE_SUBSURF; - else if( strcmp( m[i], "Optimal" ) == 0 ) - mode |= EXPP_NMESH_MODE_OPTIMAL; - else - return EXPP_ReturnPyObjError( PyExc_AttributeError, - "unknown NMesh mode" ); + "expected an int or from none to 5 strings as argument(s)" ); + + if (arg1) { + if (PyInt_Check(arg1)) { + mode = (short)PyInt_AsLong(arg1); + } + else if (PyString_Check(arg1)) { + m[0] = PyString_AsString(arg1); + for( i = 0; i < 5; i++ ) { + if( !m[i] ) break; + else if( strcmp( m[i], "NoVNormalsFlip" ) == 0 ) + mode |= EXPP_NMESH_MODE_NOPUNOFLIP; + else if( strcmp( m[i], "TwoSided" ) == 0 ) + mode |= EXPP_NMESH_MODE_TWOSIDED; + else if( strcmp( m[i], "AutoSmooth" ) == 0 ) + mode |= EXPP_NMESH_MODE_AUTOSMOOTH; + else if( strcmp( m[i], "SubSurf" ) == 0 ) + mode |= EXPP_NMESH_MODE_SUBSURF; + else if( strcmp( m[i], "Optimal" ) == 0 ) + mode |= EXPP_NMESH_MODE_OPTIMAL; + else if( m[i][0] == '\0' ) + mode = 0; + else + return EXPP_ReturnPyObjError( PyExc_AttributeError, + "unknown NMesh mode" ); + } + } + else return EXPP_ReturnPyObjError( PyExc_AttributeError, + "expected an int or from none to 5 strings as argument(s)" ); } nmesh->mode = mode; diff --git a/source/blender/python/api2_2x/Object.c b/source/blender/python/api2_2x/Object.c index b400a059781..5b59449c8ea 100644 --- a/source/blender/python/api2_2x/Object.c +++ b/source/blender/python/api2_2x/Object.c @@ -753,7 +753,7 @@ static PyObject *Object_getData( BPy_Object *self, PyObject *a, PyObject *kwd ) /* user wants only the name of the data object */ if (name_only) { - ID *id = &object->id; + ID *id = object->data; data_object = Py_BuildValue("s", id->name+2); if (data_object) return data_object; diff --git a/source/blender/python/api2_2x/doc/NMesh.py b/source/blender/python/api2_2x/doc/NMesh.py index 3f06d2bbe89..07c86cbbf55 100644 --- a/source/blender/python/api2_2x/doc/NMesh.py +++ b/source/blender/python/api2_2x/doc/NMesh.py @@ -580,8 +580,9 @@ class NMesh: Set the mode flags for this mesh. Given mode strings turn the mode "on". Modes not passed in are turned "off", so setMode() (without arguments) unsets all mode flags. - @type m: string - @param m: mode string. From none to 5 can be given: + @type m: string or int (bitflag) + @param m: mode string or int. An int (see L{Modes}) or from none to 5 + strings can be given: - "NoVNormalsFlip" - "TwoSided" - "AutoSmooth" diff --git a/source/blender/python/api2_2x/doc/Window.py b/source/blender/python/api2_2x/doc/Window.py index bde72cc815c..348749fae7e 100644 --- a/source/blender/python/api2_2x/doc/Window.py +++ b/source/blender/python/api2_2x/doc/Window.py @@ -280,13 +280,20 @@ def SetViewQuat (quat): @param quat: four floats or a list of four floats. """ -def GetViewOffset (ofs): +def GetViewOffset (): """ Get the current VIEW3D offset values. @rtype: list of floats @return: a list with three floats: [x,y,z]. """ +def SetViewOffset (ofs): + """ + Set the current VIEW3D offset values. + @type ofs: 3 floats or list of 3 floats + @param ofs: the new view offset values. + """ + def CameraView (camtov3d = 0): """ Set the current VIEW3D view to the active camera's view. If there's no |