algorithmic modeling for Rhino
how to insert new paths in the previous paths with code? ( syntax)
( sorry if there is some examples. I cant found it)
and what if the tree contains different types ? ( as is usual)
what is the tree type?
Tags:
A DataTree can just be DataTree<object> if you want to put different types of data into it.
The order of paths (and therefore branches) in a DataTree is determined entirely by the sort order of GH_Path. Basically, lower indices appear sooner than higher indices and shorter paths beat longer paths. So if you were to put these paths in order {0} {1} {0;1} {1;1} {1;0} it would be:
{0} both paths that start with zero only overlap on the first digit, therefore the shorter path wins.
{0;1}
{1} all paths that start with one only overlap on the first digit, therefore the shortest one wins.
{1;0} zero (in the second index) is lower than one, therefore this path comes first.
{1;1}
If you want to insert a path at a given index it can be quite tricky because you'll need to invent a path that 'sorts' itself in between its two neighbours. It's always possible to find such a path, for example:
{0;1;3}
<----- {0;1;3;0}
{0;1;4}
It's as simple as appending a zero (or any other digit) to the path in front of you. You do however need to make sure that the path ahead of you is not the same.
I would probably approach this in a different fashion though. I'd probably make two lists (one of GH_Path the other of List<object>) so I could happily insert and remove any paths without the sorting logic kicking in. Then, when I'm happy with the order, create a brand new DataTree<object> where I can control the exact numbering of all the paths.
--
David Rutten
david@mcneel.com
Poprad, Slovakia
you're right.
then traditional arraylist...
No, never use ArrayList. It's moot. Use List(Of Something) instead. If you don't want to commit to a specific type, then use List(Of Object). ArrayList is a left-over class from .NET 1.0 when there were no generic types yet. List(Of T) is to be preferred.
--
David Rutten
david@mcneel.com
Poprad, Slovakia
understood.
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