algorithmic modeling for Rhino
Hello!
Because GH does not allow recursion between output and input of the same component, I thought I would solve my problem through an array (or other data type) declared within my VB component, but a very "persistent" array... so that these data may be available next time control will go from there, so that I can update data the second time, so that I can modify them next time and so on.
Well, is there a way to define the array in this way?
Thank you very much.
Tags:
Hello,
One method (though I'm not sure if it is the best) is to declare your list as 'static'. It will then persist its state through the objects lifetime.
http://msdn.microsoft.com/en-us/library/z2cty7t8(v=vs.80).aspx#Y339
Such as:
Static someList = new List(Of GH_Point)
Static stepNum As Integer = 0
etc.
Cheers,
Chris
just what I wanted! thank you very much, Chris. For any beginner, like me, here's a sample VBcode:
Private Sub RunScript(ByVal x As List(Of Double), ByVal reset As Boolean, ByRef A As Object)
Static stepNum As Integer = 0 ' stepNum will be setted only the first time
If reset Then
stepNum = 0 ' stepNum will be RE-setted depending on the boolean parm "reset"
Exit Sub
End If
stepNum = stepNum + 1 ' stepNum is persistent, 'til next REset
Print("My static counter = " & stepNum) ' stepNum is growing!
' ... insert generic code here ...
' A = anyThingh
End Sub
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by