TypeError: list indices must be integers, not tuple

General discussion about TexGen.

Moderators: Martin, Developers

Post Reply
LijunGu
Regular
Posts: 30
Joined: Mon Jun 01, 2020 4:49 am

TypeError: list indices must be integers, not tuple

Post by LijunGu »

Hello Dr. Louise,

There is another question after i figure out my last concern.

Firstly, I created two demension arrays, such as:
array_test=([[0,0,1,0,0,0,1,0],[2,2,1,1,0,1,1,2]])
Node_index=([[],[]])
then, tried to create two yarns like this:
sx=3.0
h_weft=0.3
textile=CTextile()
for i in range(2):
yarn = CYarn()
for j in range(8):
if i-1<0:
N[i,j]=XYZ(j*sx,0,array_test[i,j]*h_weft)
yarn.AddNode(CNode(N[i,j]))
textile.AddYarn(yarn)
elif i-1>=0:
N[i,j]=XYZ(j*sx,0,array_test[j]*h_weft+N[i-1,j].z)
yarn.AddNode(CNode(N[i,j]))
textile.AddYarn(yarn)
AddTextile("double yarns", textile)

When i run this script, TexGen showing the TypeError: list indices must be integers, not tuple.

Could you please give me support for this topic?

Have a nice day!

Best regards!
louisepb
Project Leader
Posts: 998
Joined: Tue Dec 08, 2009 2:27 pm
Location: Nottingham

Re: TypeError: list indices must be integers, not tuple

Post by louisepb »

Hello,

It's difficult to see what's going on without the indentation - maybe you could insert as code on another occassion.

My guess is that the problem is where you are trying to set up the value for the nodes, but it's difficult to tell. This is a Python programming issue rather than a TexGen problem so you need to try to understand what the error message is telling you and look at the code line it's pointing to.

Sorry not to be more help,
Louise
Post Reply