algorithmic modeling for Rhino
Hi Khizer,
I'm not entirely sure what you're after, but you can put static variables inside the RunScript method. The value assigned to these variables will persist between subsequent calls to RunScript:
Static m_data As List(Of Double)
If (m_data Is Nothing) Then m_data = New List(Of Double)
m_data.Add(x)
You can also put variables in the class body, rather than the RunScript body. This means they'll be accessible from all functions inside the Script_Instance class. You'll need to put these additional code block:
'<Custom additional code>
Private m_data As New List(Of Double)
'</Custom additional code>
If you have a lot of data that 'belongs' together, I recommend you write a small class or structure that encapsulates it:
'<Custom additional code>
Public Class MySpecialData
Public m_data As New List(Of Double)
Public m_name As String
Public m_index As Int32
Public m_offset As Double
Public m_shape As Rhino.Geometry.Brep
End Class
...
'</Custom additional code>
Put this class in the additional block and you can use it inside all the functions within the Script_Instance class.
--
David Rutten
david@mcneel.com
Poprad, Slovakia
I think i should explain the issue with reference to the file where i wanted to apply it...
Here's the file, David you might remember the A3Array file, its the extension, i was translating the code from java, when i encountered these issues...
In VB.net script, i wanted to make functions so as to call them whenever i required to use them in my main program within that VB script, instead of copy and pasting them ... but i couldn't take the variables from Main program to functions (the bottom part of the VB Script area where additional functions and classes go), and call functions appropriately... i tried to script it in the way David advised me to, but couldn't (maybe due to my limited programming background) .. so how do i make them into functions (things i mentioned in the code) ?
Another problem that i am having is the '3 search and growth part' its not working, i am also attaching a video, of how it should work...( generated by my java program, although the one in grasshopper don't have all the function in it yet, but it should work in the similar way with the current version of GH file...) Here red squares are 1, blue = 2 and yellow=3, according to the conditions 3 should grow way quicker than the red.... i think it's not following the condition at line 508
Here's the link to the video
Do you mean you want to declare variables in one component and then use them in another? I can think of some ways of doing that which might work, but I wouldn't recommend it since it's kinda unnecessary and goes completely against the way grasshopper is supposed to work - changing one of them won't trigger an update, you can't be certain which order components will be fired in etc...
I think i should explain the issue with reference to the file where i wanted to apply it...
Here's the file, i was translating the code from java, when i encountered these issues...
In VB.net script, i wanted to make functions so as to call them whenever i required to use them in my main program within that VB script, instead of copy and pasting them ... but i couldn't take the variables from Main program to functions (the bottom part of the VB Script area where additional functions and classes go), and call functions appropriately... i tried to script it in the way David advised me to, but couldn't (maybe due to my limited programming background) .. so how do i make them into functions (things i mentioned in the code) ?
Another problem that i am having is the '3 search and growth part' its not working, i am also attaching a video, of how it should work...( generated by my java program, although the one in grasshopper don't have all the function in it yet, but it should work in the similar way with the current version of GH file...) Here red squares are 1, blue = 2 and yellow=3, according to the conditions 3 should grow way quicker than the red.... i think it's not following the condition at line 508
Here's the link to the video
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