[Bf-committers] [Bf-blender-cvs] SVN commit: /data/svn/bf-blender [13921] trunk/blender/source/blender/ python/api2_2x: Wrap UndoPush with python, needed for apricot, so changes made be scripts can have undo's as well, otherwise users undo and lo

Campbell Barton ideasman42 at gmail.com
Sun Mar 2 13:08:58 CET 2008


The problem is a script can make a change, but blender does not run an
undo push. So when the user Presses Ctrl+Z, it takes them back to
before they made the change through python.
This wont fix python scripts closing on undo.

On Sun, Mar 2, 2008 at 6:46 AM, Joe Eagar <joeedh at gmail.com> wrote:
> How does this work? is there an undo callback? or are scripts just
>  supposed to save to ID properties?
>
>  Joe
>
>
>
>  Campbell Barton wrote:
>  > Revision: 13921
>  >           http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=13921
>  > Author:   campbellbarton
>  > Date:     2008-02-29 21:45:57 +0100 (Fri, 29 Feb 2008)
>  >
>  > Log Message:
>  > -----------
>  > Wrap UndoPush with python, needed for apricot, so changes made be scripts can have undo's as well, otherwise users undo and loose changes the script made.
>  >
>  > Modified Paths:
>  > --------------
>  >     trunk/blender/source/blender/python/api2_2x/Blender.c
>  >     trunk/blender/source/blender/python/api2_2x/doc/Blender.py
>  >
>  > Modified: trunk/blender/source/blender/python/api2_2x/Blender.c
>  > ===================================================================
>  > --- trunk/blender/source/blender/python/api2_2x/Blender.c     2008-02-29 20:26:35 UTC (rev 13920)
>  > +++ trunk/blender/source/blender/python/api2_2x/Blender.c     2008-02-29 20:45:57 UTC (rev 13921)
>  > @@ -115,6 +115,7 @@
>  >  static PyObject *Blender_UnpackAll( PyObject * self, PyObject * value);
>  >  static PyObject *Blender_CountPackedFiles( PyObject * self );
>  >  static PyObject *Blender_GetPaths( PyObject * self, PyObject *args, PyObject *keywds );
>  > +static PyObject *Blender_UndoPush( PyObject * self, PyObject *args );
>  >  extern PyObject *Text3d_Init( void ); /* missing in some include */
>  >
>  >  /*****************************************************************************/
>  > @@ -201,6 +202,9 @@
>  >  static char Blender_GetPaths_doc[] =
>  >  "() - Returns a list of paths used in this blend file.";
>  >
>  > +static char Blender_UndoPush_doc[] =
>  > +"(s) - Push an undo with blenders current state.";
>  > +
>  >  /*****************************************************************************/
>  >  /* Python method structure definition.                */
>  >  /*****************************************************************************/
>  > @@ -217,8 +221,8 @@
>  >       {"GetPaths", ( PyCFunction ) Blender_GetPaths, METH_VARARGS|METH_KEYWORDS, Blender_GetPaths_doc},
>  >       {"PackAll", ( PyCFunction ) Blender_PackAll, METH_NOARGS, Blender_PackAll_doc},
>  >       {"UnpackAll", Blender_UnpackAll, METH_O, Blender_UnpackAll_doc},
>  > -     {"UpdateMenus", ( PyCFunction ) Blender_UpdateMenus, METH_NOARGS,
>  > -      Blender_UpdateMenus_doc},
>  > +     {"UpdateMenus", ( PyCFunction ) Blender_UpdateMenus, METH_NOARGS, Blender_UpdateMenus_doc},
>  > +     {"UndoPush", Blender_UndoPush, METH_VARARGS, Blender_UndoPush_doc},
>  >       {NULL, NULL, 0, NULL}
>  >  };
>  >
>  > @@ -950,6 +954,14 @@
>  >       return list;
>  >  }
>  >
>  > +static PyObject *Blender_UndoPush( PyObject * self, PyObject *args )
>  > +{
>  > +     char *str;
>  > +     if ( !PyArg_ParseTuple( args , "s" , &str ))
>  > +             return EXPP_ReturnPyObjError( PyExc_TypeError, "expected a string" );
>  > +     BIF_undo_push(str);
>  > +     Py_RETURN_NONE;
>  > +}
>  >
>  >  static PyObject *Blender_UnpackModesDict( void )
>  >  {
>  >
>  > Modified: trunk/blender/source/blender/python/api2_2x/doc/Blender.py
>  > ===================================================================
>  > --- trunk/blender/source/blender/python/api2_2x/doc/Blender.py        2008-02-29 20:26:35 UTC (rev 13920)
>  > +++ trunk/blender/source/blender/python/api2_2x/doc/Blender.py        2008-02-29 20:45:57 UTC (rev 13921)
>  > @@ -240,3 +240,9 @@
>  >       upon exiting) when this function is called, so the data in Blender isn't
>  >       lost.
>  >    """
>  > +def UndoPush (message):
>  > +  """
>  > +  Sets an undo at the current state.
>  > +  @param message: Message that appiers in the undo menu
>  > +  @type message: string
>  > +  """
>  > \ No newline at end of file
>  >
>  >
>  > _______________________________________________
>  > Bf-blender-cvs mailing list
>  > Bf-blender-cvs at blender.org
>  > http://lists.blender.org/mailman/listinfo/bf-blender-cvs
>  >
>  >
>
>  _______________________________________________
>  Bf-committers mailing list
>  Bf-committers at blender.org
>  http://lists.blender.org/mailman/listinfo/bf-committers
>


More information about the Bf-committers mailing list