Oops - the 'vertList' variables in that should be 'vertList1':
for i in xrange(0, len(vertList1), 2):
a = vertList1[i]
b = vertList1[i + 1]
for point in vertList2:
doTest(a, b, point)
- Paul
On Fri, Apr 30, 2010 at 4:28 PM, Paul Molodowitch <[email protected]>wrote:
> Alternative way to iterate by pairs through a list, which will take up less
> memory (which, if these are vertices, may be useful, since vert lists can
> get pretty big):
>
> for i in xrange(0, len(vertList1), 2):
> a = vertList[i]
> b = vertList[i + 1]
> for point in vertList2:
> doTest(a, b, point)
>
> - Paul
>
>
> On Fri, Apr 30, 2010 at 3:00 PM, Keir <[email protected]> wrote:
>
>> I also don't quite understand the problem you are trying to solve. I
>> feel that you may be making it more complicated than it needs to be.
>> But in any case the following is a way of looping a pair of values
>> from a list using list slicing and zip.
>>
>> for a, b in zip( vertList1[:-1], vertList1[1:] ):
>> for point in vertList2:
>> doTest()
>>
>> Keir
>>
>> On May 1, 8:51 am, "Ofer Koren" <[email protected]> wrote:
>> > what do you mean "x/y values for pSphere1 faces"? where is the 'z'
>> > coordinate? is that for the center of the face or each of the vertices
>> of
>> > that face?
>> >
>> > maybe you could state the context of this problem?
>> >
>> > From: [email protected]
>> > [mailto:[email protected]] On Behalf Of Jon Mills
>> > Sent: Friday, April 30, 2010 3:31 AM
>> > To: [email protected]
>> > Subject: Re: [Maya-Python] repeat code?
>> >
>> > vertList1 is the y values of pSphere1 faces
>> > vertList2 is the x values of pSphere1 faces
>> >
>> > ok im trying to match up faces which have the same vertices,
>> > so say from a sphere pSphere1[0], y1, y2 and pSphere1[20], x1, x2 are
>> the
>> > same verts
>> >
>> > then using the dot product of pSphere1[0] and pSphere1[20]
>> > ill be finding the difference pSphere1[0] - pSphere1[20]
>> >
>> > hope this helps
>> >
>> > --http://groups.google.com/group/python_inside_maya
>> >
>> > --http://groups.google.com/group/python_inside_maya
>>
>> --
>> http://groups.google.com/group/python_inside_maya
>>
>
>
--
http://groups.google.com/group/python_inside_maya