Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2007-04-21 03:33:56 +0400
committerCampbell Barton <ideasman42@gmail.com>2007-04-21 03:33:56 +0400
commitd76778f0e404196fbc783647f630ae6aef9a734a (patch)
treebab6430233b93515b77e1ffee713f8e34a1aac46 /source
parentcbfeab7e45a6b22a1140a369085f641d20d3e268 (diff)
2 new python functions for the NLA.
action.getChannelNames() and action.renameChannel(from, to) editaction.c - maximum new name length was too short
Diffstat (limited to 'source')
-rw-r--r--source/blender/python/api2_2x/NLA.c44
-rw-r--r--source/blender/python/api2_2x/doc/NLA.py15
-rw-r--r--source/blender/src/editaction.c6
3 files changed, 62 insertions, 3 deletions
diff --git a/source/blender/python/api2_2x/NLA.c b/source/blender/python/api2_2x/NLA.c
index be15e24d193..12d948120dd 100644
--- a/source/blender/python/api2_2x/NLA.c
+++ b/source/blender/python/api2_2x/NLA.c
@@ -88,6 +88,8 @@ struct PyMethodDef M_NLA_methods[] = {
static PyObject *Action_setActive( BPy_Action * self, PyObject * args );
static PyObject *Action_getFrameNumbers(BPy_Action *self);
static PyObject *Action_getChannelIpo( BPy_Action * self, PyObject * args );
+static PyObject *Action_getChannelNames( BPy_Action * self );
+static PyObject *Action_renameChannel( BPy_Action * self, PyObject * args );
static PyObject *Action_verifyChannel( BPy_Action * self, PyObject * args );
static PyObject *Action_removeChannel( BPy_Action * self, PyObject * args );
static PyObject *Action_getAllChannelIpos( BPy_Action * self );
@@ -107,6 +109,10 @@ static PyMethodDef BPy_Action_methods[] = {
"() - get the frame numbers at which keys have been inserted"},
{"getChannelIpo", ( PyCFunction ) Action_getChannelIpo, METH_VARARGS,
"(str) -get the Ipo from a named action channel in this action"},
+ {"getChannelNames", ( PyCFunction ) Action_getChannelNames, METH_NOARGS,
+ "() -get the channel names for this action"},
+ {"renameChannel", ( PyCFunction ) Action_renameChannel, METH_VARARGS,
+ "(from, to) -rename the channel from string to string"},
{"verifyChannel", ( PyCFunction ) Action_verifyChannel, METH_VARARGS,
"(str) -verify the channel in this action"},
{"removeChannel", ( PyCFunction ) Action_removeChannel, METH_VARARGS,
@@ -283,6 +289,44 @@ static PyObject *Action_getChannelIpo( BPy_Action * self, PyObject * args )
return Ipo_CreatePyObject( chan->ipo );
}
+static PyObject *Action_getChannelNames( BPy_Action * self )
+{
+ PyObject *list = PyList_New( BLI_countlist(&(self->action->chanbase)) );
+ bActionChannel *chan = NULL;
+ int index=0;
+ for( chan = self->action->chanbase.first; chan; chan = chan->next ) {
+ PyList_SetItem( list, index, PyString_FromString(chan->name) );
+ index++;
+ }
+ return list;
+}
+
+static PyObject *Action_renameChannel( BPy_Action * self, PyObject * args )
+{
+ char *chanFrom, *chanTo;
+ bActionChannel *chan;
+
+ if( !PyArg_ParseTuple( args, "ss", &chanFrom, &chanTo ) )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "2 strings expected" );
+
+ chan = get_action_channel( self->action, chanFrom );
+ if( !chan )
+ return EXPP_ReturnPyObjError( PyExc_ValueError,
+ "no channel with that name" );
+ if (strlen(chanTo) > 31)
+ return EXPP_ReturnPyObjError( PyExc_ValueError,
+ "new name greater then 31 characters long" );
+
+ if (get_action_channel( self->action, chanTo ))
+ return EXPP_ReturnPyObjError( PyExc_ValueError,
+ "channel target name alredy exists" );
+
+ strcpy(chan->name, chanTo);
+
+ Py_RETURN_NONE;
+}
+
/*----------------------------------------------------------------------*/
static PyObject *Action_verifyChannel( BPy_Action * self, PyObject * args )
{
diff --git a/source/blender/python/api2_2x/doc/NLA.py b/source/blender/python/api2_2x/doc/NLA.py
index e088b277103..adfcf77d965 100644
--- a/source/blender/python/api2_2x/doc/NLA.py
+++ b/source/blender/python/api2_2x/doc/NLA.py
@@ -109,6 +109,21 @@ class Action:
@return: the Ipos for all the channels in the action
"""
+ def getChannelNames():
+ """
+ Returns a list of channel names
+ @rtype: list
+ @return: the channel names that match bone and constraint names.
+ """
+
+ def renameChannel(nameFrom, nameTo):
+ """
+ rename an existing channel to a new name.
+
+ if the nameFrom channel dosnt exist or the nameTo exists, an error will be raised.
+ @return: None
+ """
+
import id_generics
Action.__doc__ += id_generics.attributes
diff --git a/source/blender/src/editaction.c b/source/blender/src/editaction.c
index 0a812c3cd2c..db81264b7ef 100644
--- a/source/blender/src/editaction.c
+++ b/source/blender/src/editaction.c
@@ -2964,8 +2964,8 @@ static void clever_achannel_names(short *mval)
strcpy(str, achan->name);
protect= (achan->flag & ACHAN_PROTECTED);
expand = (achan->flag & ACHAN_EXPANDED);
-
- add_numbut(but++, TEX, "ActChan: ", 0, 24, str, "Name of Action Channel");
+
+ add_numbut(but++, TEX, "ActChan: ", 0, 31, str, "Name of Action Channel");
add_numbut(but++, TOG|SHO, "Expanded", 0, 24, &expand, "Action Channel is Expanded");
add_numbut(but++, TOG|SHO, "Protected", 0, 24, &protect, "Channel is Protected");
}
@@ -2975,7 +2975,7 @@ static void clever_achannel_names(short *mval)
strcpy(str, conchan->name);
protect= (conchan->flag & CONSTRAINT_CHANNEL_PROTECTED);
- add_numbut(but++, TEX, "ConChan: ", 0, 24, str, "Name of Constraint Channel");
+ add_numbut(but++, TEX, "ConChan: ", 0, 29, str, "Name of Constraint Channel");
add_numbut(but++, TOG|SHO, "Protected", 0, 24, &protect, "Channel is Protected");
}
#if 0 /* tempolarily disabled until there is actually something to display */