Can't use FOR statement successfully

I am new to dynamo and I am a Chinese. so I am sorry if my poor English misunderstands you.


The screenshot above shows that I want to create 8*8 coordinate systems whose Z-values of origin points are i+j. but unfortunately it returns a list of lists full of null values. In fact if I use the sentence “cs3[i][j]=i+j;”, it will return the correct list of lists. So the problem may not be related to for statement?
by the way, I don’t really understand “imperative” after reading the designscript documentation. Could you briefly explain it ?
urgent because of deadline. any help will be appreciated. Thank you very much.

Above the second for loop you need to index to the next rank of cs3 so:
cs3[i] = {}
Without looking at your incoming list, there maybe be an issue with that too

Thank you for your help. I have followed your advice but it still doesn’t work. The forum says that new users can’t upload attachments, so I have to show you the screenshot.

1 Like

@1549041984 I’m not sure what you are trying to achieve but it works. Maybe your Dynamo version?

I’m on Dynamo 1.1 (english version)

2 Likes

@1549041984 Firstly check your input list is 2D and contains no null objects.

Be aware that Dynamo 1.0.0 DesignScript has a bug using static methods in Imperative blocks, see this

If that is the cause of the problem, then simply declare the Vector.ZAxis() outside of the Imperative block, or have it as an input to the function.

Also, I’m guessing you’re doing this to learn DesignScript, which is fine, but its also pointless considering you could achieve the same thing using Translate with cross-product lacing.

you are right. It works!!! Thank you very much. I will give up 0.9 version forever.

YES I forgot that I could use cross product lacing. And the problem has been solved by simply updating the latest Dynamo version, just like anther reply. thanks again for your detailed help.

Please mark the solution so this topic can be closed