algorithmic modeling for Rhino
Hello all,
if I add a VB component in grasshopper and set a for-loop i only will get the last number? Do you know some help to fix?
Dim i As Integer
For i = 1 To 10
A = i
Next i
give just A = 10 back to record tool. Maybe VB is to fast?
thanks for your help! best regards treb.
Tags:
Hi Trebor,
all the code inside a VB component executes before it returns control to Grasshopper. It doesn't matter how quick or how slow the code is. If you want to output a list of numbers, you have to declare a list of numbers:
Dim numbers As New List(Of Integer)
For i As Integer = 1 To 10
numbers.Add(i)
Next
A = numbers
--
David Rutten
david@mcneel.com
hey david,
big thanks for your answer.
but I want to execute an operation with 10 diffrent points - instead of a slider it should run automatically (for X=1 and X=2 and .. and X=10). do you see any way to do this?
thank you, treb.
I don't understand exactly what you're after. What do you want the input to the VB component to be and what should the output be?
--
David Rutten
david@mcneel.com
input for the VB should be only a start button.
in the output their should be coordinates for a mesh. i want to record the results from the mesh to a txt file (no problem). but the coordinates should be run automatically in a defined area from e.g 1 to 10 (output from VB, input to mesh).
do you understand?
sorry for my bad english.
greats
Grasshopper is an event-based solver, meaning that each solution is triggered by an expiration event. A new solution is then computed and the solver goes back 'asleep'. Because of this it is difficult to use GH as an animated system, which continually loops and changes the data. Kangaroo, Hoopsnake and Galapagos have a loop that runs outside of the solver and it triggers the solver on every iteration. This requires a lot of code and cannot easily be done from within a VB script component.
It can be I still misunderstand the problem, but I attached a file which generates a list of points to be used for a mesh.
--
David Rutten
david@mcneel.com
hm, i think david is right. i want to have the index, because the index is the number i want.
thanks for your answers!
There is also another way to do this. Use GH_Timer (you can use system.timers.timer but it can be harmful for gh), to expire solution. The code for vb component (the editor within the gh) should look like :
private sub runscript (bla,bla,bla byval your inputs and byref outputs)
counter +=1
if x then
counter = 0
end if
a = counter
end sub
'<Custom additional code>
dim counter as integer
'</Custom additional code>
End Class
now using gh_timer you can increase the counter with some given interval.
The thread.sleep actually freezes your computation, which is not really convinient.
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2025 Created by Scott Davidson.
Powered by