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
diff options
context:
space:
mode:
authorTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2010-05-23 21:11:44 +0400
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2010-05-23 21:11:44 +0400
commit96e79172a010cba6bc826f570832ef4b355ea0cd (patch)
tree5e7bee49170faff126fa52d8fd389642876e4021 /source/blender/freestyle/intern/python/BPy_SShape.cpp
parent2212564f1804e3cc866003b226eac89575d53ade (diff)
Made object names accessible from within style modules.
ViewShape objects in the view map, as well as SShape objects that can be retrieved with ViewShape::sshape(), now have a getName() method that returns the name of the object from which each shape is created. For instance, visible feature edges of specific mesh objects (e.g., Cube.001 and Cube.002) can be selected using custom predicate ObjectNamesUP1D as follows: class ObjectNamesUP1D(UnaryPredicate1D): def __init__(self, names): UnaryPredicate1D.__init__(self) self._names = names def getName(self): return "ObjectNamesUP1D" def __call__(self, viewEdge): return viewEdge.viewShape().getName() in self._names upred = AndUP1D(QuantitativeInvisibilityUP1D(0), ObjectNamesUP1D(["Cube.001", "Cube.002"])) Operators.select(upred)
Diffstat (limited to 'source/blender/freestyle/intern/python/BPy_SShape.cpp')
-rw-r--r--source/blender/freestyle/intern/python/BPy_SShape.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/source/blender/freestyle/intern/python/BPy_SShape.cpp b/source/blender/freestyle/intern/python/BPy_SShape.cpp
index 512a19359a5..65951182f10 100644
--- a/source/blender/freestyle/intern/python/BPy_SShape.cpp
+++ b/source/blender/freestyle/intern/python/BPy_SShape.cpp
@@ -229,6 +229,37 @@ static PyObject * SShape_setId( BPy_SShape *self , PyObject *args) {
Py_RETURN_NONE;
}
+static char SShape_getName___doc__[] =
+".. method:: getName()\n"
+"\n"
+" Returns the name of the SShape.\n"
+"\n"
+" :return: The name string.\n"
+" :rtype: str\n";
+
+static PyObject * SShape_getName( BPy_SShape *self ) {
+ return PyUnicode_FromString( self->ss->getName().c_str() );
+}
+
+static char SShape_setName___doc__[] =
+".. method:: setName(name)\n"
+"\n"
+" Sets the name of the SShape.\n"
+"\n"
+" :arg name: A name string.\n"
+" :type name: str\n";
+
+static PyObject * SShape_setName( BPy_SShape *self , PyObject *args) {
+ char *s;
+
+ if(!( PyArg_ParseTuple(args, "s", &s) ))
+ return NULL;
+
+ self->ss->setName(s);
+
+ Py_RETURN_NONE;
+}
+
// const Material & material (unsigned i) const
// const vector< Material > & materials () const
// void SetMaterials (const vector< Material > &iMaterials)
@@ -244,6 +275,8 @@ static PyMethodDef BPy_SShape_methods[] = {
{"getEdgeList", ( PyCFunction ) SShape_getEdgeList, METH_NOARGS, SShape_getEdgeList___doc__},
{"getId", ( PyCFunction ) SShape_getId, METH_NOARGS, SShape_getId___doc__},
{"setId", ( PyCFunction ) SShape_setId, METH_VARARGS, SShape_setId___doc__},
+ {"getName", ( PyCFunction ) SShape_getName, METH_NOARGS, SShape_getName___doc__},
+ {"setName", ( PyCFunction ) SShape_setName, METH_VARARGS, SShape_setName___doc__},
{NULL, NULL, 0, NULL}
};