[Bf-python] Did .setEuler change between 2.32 and 2.33?

Stephen Swaney sswaney at swbell.net
Wed May 5 19:46:39 CEST 2004


Joseph Gilbert wrote:
> 
> Yep. Originally this function took a f,f,f or a [f,f,f]. The mathutils lib
> now has support for real eulers so this function now takes either [f,f,f],
> or PyEuler type. I didn't continue the support for f,f,f, because it is
> looking for 1 object not three. However, I think that this could be
> reimplemented as f,f,f, [f,f,f] or PyEuler if the ParseTuple var is "O|ff"
> (now that I think about it. I'll see if I can change it :)

I believe our goal, not always achieved, was to maintain 
backward compatibility.  At least up to some point where
we change over.

I was playing with this late last night, but decided
not to do a checkin at 2am.  One possible solution is this:

-- 
Stephen Swaney			
sswaney at swbell.net
-------------- next part --------------
	PyObject* ob;

	/* do we have 3 floats? */
	if (PyObject_Length (args) == 3) {
		status = PyArg_ParseTuple (args, "fff", &rot1, &rot2, &rot3);
		if (!status)
			return EXPP_ReturnPyObjError (PyExc_AttributeError,
					"expected  3 floats");
	//test to see if it's a list or a euler
 	}else if ( PyArg_ParseTuple (args, "O", &ob)){

		if(EulerObject_Check(ob)){
			rot1 = ((EulerObject*)ob)->eul[0];
			rot2 = ((EulerObject*)ob)->eul[1];
			rot3 = ((EulerObject*)ob)->eul[2];
		}else if(PySequence_Check(ob )){
			status = PyArg_ParseTuple (args, "(fff)", 
						   &rot1, &rot2, &rot3);
			if( !status)
				return EXPP_ReturnPyObjError (PyExc_AttributeError,
							      "expected list argument of 3 floats");

		}else{
			Py_DECREF (args);
			return (PythonReturnErrorObject (PyExc_AttributeError,
				"expected list/tuple of 3 floats or euler"));
		}
	}else{
		return (PythonReturnErrorObject (PyExc_AttributeError,
				"unknown type passed to function (setEuler)"));
	}


More information about the Bf-python mailing list