[vtkusers] How to use GetTupleValue(i, array) in python?

David Doria daviddoria+vtk at gmail.com
Sat Dec 19 06:27:23 EST 2009


On Fri, Dec 18, 2009 at 10:19 PM, David Gobbi <david.gobbi at gmail.com> wrote:
> On Fri, Dec 18, 2009 at 7:51 PM,  <lynx.abraxas at freenet.de> wrote:
>> On 18/12/09 21:07:03, lynx.abraxas at freenet.de wrote:
>>>     for i in range(0, PointNormalArray.GetNumberOfTuples()):
>>>         PointNormalArray.GetTupleValue(i, pointNormal) #make sure  pointNormal is big enough!
>>>
>>> And I get the python error "AttributeError: GetTupleValue".
>>> So I wonder how do I have to this in python?
>>
>> With David D.'s advice I found GetTuple3(i) which works fine. Is that the correct function to use here?
>
> Yup, the numbered GetTuple methods are the proper methods for getting
> tuples from arrays in python.
>
> Methods like "GetTupleValue(int i, double *tuple)" aren't wrapped in
> python unless they have a signature like GetTupleValue(int i, double
> tuple[3]) so that the wrappers know how large the array is.
>
> Likewise,  methods like "double *GetTuple(int i)" aren't wrapped
> unless there is a hint so that the wrappers know how many values will
> be returned.
>
> The wrappers don't do anything fancy like check how many components an
> array has in order to find out what size of tuple to use.  The
> wrapping of a method is determined only by the method signature and
> the hints in VTK/Wrapping/hints.
>
>  David

Lynx,

When you get things like this figured out, please add an example! The
Python section is pretty sparse!

http://www.cmake.org/Wiki/VTK/Examples#Example_Usage_.28Python.29

Thanks,

David



More information about the vtkusers mailing list