[Bf-python] setSel patch

Campbell Barton cbarton at metavr.com
Mon May 31 07:43:53 CEST 2004


Hi, the initial name change and code changes are good, should I make a 
patch against the cvs?
I thaught the get/setSel was in keeping with everything but it dosent 
realy matter.
Ill probablt use .sel more anyway..... (We could _Only_ have it as a 
class veriable and not bother with setSelection, Select)
The verts only have a .sel so it would be consistant and it seems a bit 
silly to add 3 ways to do somthing when only 1 is needed.

Just the ability to save/set and unset selections is nice, id like to be 
able to write scripts using this.

Could do things like (Select objects mesh's with same number of verts)

- Cam



Joseph Gilbert wrote:

>Hi,
>	Just a few comments:
>Could this be called isSelected() and Select(TRUE/FALSE)? instead of
>getSel/setSel?
>Also you - careful not to define variable before you done declaring them in
>C. ie.
>+  Base *base;
>+  base= FIRSTBASE;
>+
>+  PyObject *sel;
>
>i believe it's better to do this:
>+  Base *base;
>+  PyObject *sel;
>+
>+  base= FIRSTBASE;
>
>There is a warning maybe here that this only applies to the current scene
>because FIRSTBASE and countall() use the G.scene variable.
>
>I made a few mods to the functions but you can see if you like them.
>static PyObject *Object_isSelected (BPy_Object *self)
>{
>	Base *base;
>
>	base= FIRSTBASE;
>	while (base) {
>		if (base->object == self->object)	{
>			if (base->flag & SELECT) {
>				Py_INCREF (Py_True);
>				return Py_True;
>			} else {
>				Py_INCREF (Py_False);
>				return Py_False;
>			}
>		}
>		base= base->next;
>	}
>
>	Py_INCREF (Py_None);
>    return (Py_None);
>}
>
>static PyObject *Object_Select (BPy_Object *self, PyObject *args)
>{
>  Base *base;
>  int sel;
>
>  base= FIRSTBASE;
>  if (!PyArg_ParseTuple (args, "i", &sel))
>		return EXPP_ReturnPyObjError
>		   (PyExc_TypeError, "expected an int, 0 or 1");
>
>    while (base) {
>		if (base->object == self->object){
>			if (sel){
>				base->flag |= SELECT;
>				self->object->flag= base->flag;
>			} else {
>				base->flag &= ~SELECT;
>				self->object->flag= base->flag;
>			}
>			break;
>		}
>		base= base->next;
>    }
>	countall();
>
>    Py_INCREF (Py_None);
>    return (Py_None);
>}
>
>Just a suggestion :) Anyway's I was looking at the apply_object() function.
>This definately looks scary. My suggestion is to not change the /src code
>and just take what you need for python. BASEACT/TESTBASELIB will only work
>on the active selected base/object - careful with these.
>
>Another way to do this is instead of calling a monster function (and it look
>like there could be a few :) in the object module you could test the object
>and call non-static visible functions from the other Datatype modules:
>static PyObject *Object_appyRotation(PyObject *self)
>{
>	if(object->type = mesh)
> 		success = NMesh_applyRot(self->object)
>	if(object->type = armature)
>		success = Armature_applyRot(self->object)
>	return PyNone
>}
>
>and in Armature...
>int Armature_applyRot(PyObject *object)
>{
>	success = do the armature specific code....
>	return success
>}
>
>This would be a matter of cut/pase from the different CASE: statements in
>the /src code. Just another idea :)
>
>
>_______________________________________________
>Bf-python mailing list
>Bf-python at blender.org
>http://www.blender.org/mailman/listinfo/bf-python
>
>
>  
>


-- 
Campbell J Barton

133 Hope Street
Geelong West, Victoria 3218 Australia

URL:    http://www.metavr.com
e-mail: cbarton at metavr.com
phone: AU (03) 5229 0241




More information about the Bf-python mailing list