algorithmic modeling for Rhino
I need to create an empty data tree, and the only way I've found so far is to create the tree with dummy data, and then call ClearData() on the tree (to remove the data while preserving branch structure).
Is this "best practice"? Or is there a better way?
Thanks
Tags:
I'm not sure if this is the best way but this seems to generate a datatree with branches but nothing inside of them:
Dim dt As New datatree(Of Object)
For i As Integer = 0 To 9
dt.addrange(New list(Of Object), New gh_path(i))
Next
a = dt
you can create empty branches in loops also. In reality once you do the line
Dim dt As New DataTree(Of Object)
you have created an empty datatree. If it needs branches then you need to add something to it. For an if/then statement if you want the thing to add an empty branch you can write the word "nothing" and it will do that. The following script can create a totally empty datatree.
For i As int32 = 0 To 5
For j As int32 = 0 To 20
dt.add(Nothing, New GH_Path(i))
Next
Next
a = dt
Yes, I needed an empty tree with some branch structure.
I'm writing in C#, not VB, but isn't this in C#:
Add(null, somePath);
equivalent to adding "Nothing" in VB? If so, then it still adds something...a null, and calling ClearData() is still needed to make the tree empty.
Try my method, it doesn't create null items.
You can also use the DataTree<T>.EnsurePath method. Which will add an empty branch if the path doesn't yet exist.
--
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
© 2024 Created by Scott Davidson. Powered by