algorithmic modeling for Rhino
It would be really useful to have 'graft very nth' component.
basically making a new path not for every element in a list, but for every nth, so I could pick out pairs of n elements. I have a VB component for that, but would be great to make it an integral part, I think.
Peter
Tags:
I know this is an old post but does this exist now? If not, Peter, would you mind sharing your VB component?
I think Cull Pattern will do this. After choosing the pattern select Graft at the output.
Yes.. I have some allocation components for this use..
I will post my components soon..
It includes Allocation with Branches, Allocation with # of Items..
Anyway, it can be done with path mapper.. (using %, \ )
Thanks all. Chris or Jissi, any slightly more specific instruction on either of these methods would be great. Cull patterns, splitting masks etc are all still quite unknown territory for me. Thanks again
I post some useful components for List Management..
http://www.grasshopper3d.com/profiles/blogs/tree8-list-management-c...
Thanks for the phenomenally fast reply, they are a great little set of components. Much appreciated.
see attached the VB Component
not yet testing in the latest GH though ...
hope this is useful,
Peter
Thanks Peter, it's absolutely spot on and works just fine in 0.8.0061. Nice for me to see what's going on inside as well, should be helpful for writing VB for myself
The script doesn't work for multiple lists..
I revised your script in two alternatives..
It collects data not as dataList but as dataTree..
#1
Private Sub RunScript(ByVal tree_in As DataTree(Of Object), ByVal n As Integer, ByRef A As Object, ByRef B As Object)
'your code goes here…
Dim tree_out As New DataTree(Of Object)
Dim count As Int32 = 0
Dim branch As Int32 = 0
For i As Int32 = 0 To tree_in.Paths.Count - 1
Dim path As GH_Path = tree_in.Paths(i)
Dim listdata As List(Of Object) = tree_in.Branches(i)
For j As Int32 = 0 To listdata.Count - 1
Dim newpath As GH_Path = path.AppendElement(branch)
count += 1
If (count >= n) Then
count = 0
branch += 1
End If
tree_out.Add(listdata(j), newpath)
Next
count = 0
branch = 0
Next
A = tree_out
End Sub
#2
Private Sub RunScript(ByVal tree_in As DataTree(Of Object), ByVal n As Integer, ByRef A As Object, ByRef B As Object)
'your code goes here…
Dim tree_out As New DataTree(Of Object)
Dim count As Int32 = 0
Dim branch As Int32 = 0
For i As Int32 = 0 To tree_in.Paths.Count - 1
Dim path As GH_Path = tree_in.Paths(i)
Dim listdata As List(Of Object) = tree_in.Branches(i)
Dim itemcount As Int32 = listdata.Count
Dim loops As Int32 = Math.Floor(itemcount / n)
Dim allocated As Int32 = loops * n
For j As Int32 = 0 To loops - 1
tree_out.AddRange(listdata.GetRange(j * n, n), path.AppendElement(j))
Next
If (allocated < itemcount) Then
tree_out.AddRange(listdata.GetRange(allocated, itemcount - allocated), path.AppendElement(loops))
End If
Next
A = tree_out
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