algorithmic modeling for Rhino
Hello all,
I have a general question regarding definition of arrays / writing to arrays in VB:
Attached code excerpt writes the requested values to the array, but it just creates one path, not 2 as would like.
I want to have a new row for each increment of the first loop (a)
How can I do this in VB?
Also, how can I define the array as dynamic?
(The code is abstracted, it's not meant to work like this..! Just to show the idea..)
Thanks a lot for any help!
Philipp
-----------------------------------
Dim Array (10,10) As On3dPoint
For a = 0 To A.Count() - 1
Dim n As Integer = 0
For b = 0 To B.Count() - 1
For c = 0 To C.Count() - 1
Array(a, n) = point
Next
Next
Next
-----------------------------------
Tags:
Hi Philipp,
you can create multi-dimensional arrays in VB, but you cannot assign them to output parameters. Grasshopper only deals with individual items, one dimensional lists or data trees.
Do you want to assign this data to an output or is it only for internal use?
--
David Rutten
david@mcneel.com
Poprad, Slovakia
Hi David,
thanks for the quick response!
For now I intended to assign the data to an output, because I want to use FitSphereToPoints (for each row individually), and I'm using Grasshopper 0.6.0055. VB doesn't have the functionality here yet, right?
Once I have found a way to do it internally, I'd prefer that!
Do you have another idea on how to calculate a point with equal/averaged distance to several other points(more than three - so I can't use the circle through 3 points)?
If not, can I somehow write the data to a list or tree for output, so that each first-level loop will create a (an equivalent to) new row?
Philipp
I don't remember when DataTrees were added and when they have undergone changes. Fitting spheres to points can be done in fairly recent versions of RhinoCommon, but I see you're still using the old SDK.
This is how I'd write your code in RhinoCommon flavoured VB:
Dim i As Int32 = 9
Dim j As Int32 = 9Dim points(,) As Point3d
ReDim points(i, j)For a As Int32 = 0 To i
For b As Int32 = 0 To j
points(i, j) = New Point3d()
Next
Next
However, if you can use a recent RhinoCommon version, you probably don't even need multi-dimensional arrays.
--
David Rutten
david@mcneel.com
Poprad, Slovakia
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
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by