algorithmic modeling for Rhino
Hi Folks,
I know this has to be super easy, but it's been eluding me...I have a long list of strings in grasshopper in the following (shortened) structure:
{0}
(0) x.xxxx, y.yyyy
(1) x.xxxx, y.yyyy
(2) x.xxxx, y.yyyy
{1}
(0) x.xxxx, y.yyyy
(1) x.xxxx, y.yyyy
(2) x.xxxx, y.yyyy
I would like to use a VB script component to spit out a list of strings in the following format so I can save them in a CSV file:
0, x.xxxx, y.yyyy
0, x.xxxx, y.yyyy
0, x.xxxx, y.yyyy
1, x.xxxx, y.yyyy
1, x.xxxx, y.yyyy
1, x.xxxx, y.yyyy
I've searched around the discussion board and found the following code snippet:
Private Sub RunScript(ByVal x As DataTree(Of Object), ByVal y As DataTree(Of Object), ByRef A As Object)
Dim zones As New List(Of String)
Dim table As New List(Of Int32)
For i As Int32 = 0 To x.BranchCount - 1
Dim path As Grasshopper.Kernel.Data.GH_Path = x.path(i)
If (table.Contains(path(0))) Then Continue For
table.Add(path(0))
For j As Int32 = 0 To x.DataCount 'DataCount returns all items in tree?!
zones.Add(path(0).ToString())
Next
Next
A = zones
End Sub
I modified it a bit by nesting another for-next loop to spit out the repeating path index. I was hoping that x.DataCount would return the number of items in that particular path, but it appears to return the total number of items in the tree.
The question: How do I return the number of individual entities in a particular path?
Is there a simpler way, perhaps without scripting?
And, in general, where's a good go-to to find a list of GH classes and their methods as well as explanations. If I saw it all in one place, it might be easier for me to understand how this is all structured, rather than seeing little bits here and there...
Thanks!
Rhino v5x64
GH 0.8.0066
Tags:
Didn't test this at all...
Dim output As New System.Text.StringBuilder()
For k As Int32 = 0 To data.BranchCount - 1
Dim path As GH_Path = data.Path(k)
Dim idx As Int32 = path.InternalPath(path.Length - 1)
For Each item As String In data.Branch(path)
If (item Is Nothing) Then Continue For
output.AppendLine(String.Format("{0}, {1}", idx, item))
Next
Next
A = output.ToString()
--
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