algorithmic modeling for Rhino
Tags:
Hi Paul,
this is a bit weird:
Dim pathindex As Int32
pathindex = x.Path(g).ToString
if pathindex is defined as an integer, you cannot assign a string to it. You can only assign integers or types that know how to upcast themselves to integers (such as shorts and bytes).
A path in a datatree is an array of integers, not a single number. So, when you ask for x.Path(g) you get an instance of a GH_Path class, which stores a bunch of integers on the inside and provides some methods of accessing and modifying them. Both of the following two approaches create a new list of integers filled with the first number in each path:
Dim indices As New List(Of Int32)
For i As Int32 = 0 To x.BranchCount - 1
indices.Add(x.Path(i)(0))
Next
A = indices
'---------------------------
Dim indices As New List(Of Int32)
For Each path As GH_Path In x.Paths
indices.Add(path(0))
Next
A = indices
--
David Rutten
david@mcneel.com
Poprad, Slovakia
Thank you very much, David.
Welcome to
Grasshopper
© 2025 Created by Scott Davidson.
Powered by