Grasshopper

algorithmic modeling for Rhino

VB.Net For Statement

Hello,

I have a simple formula in my Grasshopper file, and I need all values for each i starting from 0 to LWL as an output for Cb

Views: 433

Attachments:

Replies to This Discussion

It would be something like this:

Dim Cb_list As New list(Of Double)
For i As Integer = 0 To LWL
Cb_list.add(Displacement / LWL / B / T)
Next
Cb = Cb_list

But there's something wrong in that formula. You have to include the 'i' variable somewhere. 0 to LWL will result in LWL+1 iterations. You are also dividing by 0.

Thank you. I will debug my formula. My interest was for listing intermediate values.

Well, I have tried simple formulas, the result is the same from i to n in the panel string.

I need the values calculated for each i listed. Maybe you can help me again with a simple example.

Thank you.

What value is 'i' supposed to represent? If it's the length at the waterline, the formula should be:

Displacement / (i * B * T)

the first result will be for lwl = 0, the second for lwl = 1, the third for lwl = 2 and so on until it reaches the value you have set to the LWL input.

You'll also notice that you are dividing by 0, so i'd sujest you change the for statement to:

for i as integer = 1 to LWL

Hello,

Vicente showed me how to list values for a FOR statement. I'd like to do the same but in Python.

I'm tired of research, it's so confusing.

And I still have another problem: when I use a list of numbers as an input for another VB or Python component I get as an output i values of a formula wich even don't use the list.

It's no hurry for converting the FOR statement.

I've uploaded the script, maybe I get lucky.

Thank you!

Attachments: