C# component with Split Tree Input

Greetings:
I’m writing a C# component that will be parsing a large data tree and I’d like the user to be able to input Split-Tree like parsing notation. For example:
{1;3-5}
to select all branches that start with 1 and end in 3, 4, or 5. Is there a simple way to go about that? Some input type I’ve missed, perhaps? I see AddPathParameter but I have no idea what it is.

The Split-Tree component uses a Text parameter for the masks. These text strings are then parsed into GH_TreeRules objects, that can be used to operate on the tree paths.

1 Like

Paths are the actual tree branch indexer types, i.e. {0;0;4;1}. They do not allow for more advanced notation like the Split Tree component inputs. Like Menno says, you just need to have a Text input parameter and then convert the strings into rules. You can use the GH_TreeRules.FromString() static method (be sure to handle exceptions thrown by this method just in case).

Once you have a valid GH_TreeRules instance, you need to iterate over the paths in your data tree and use the Apply() method on each one to see if that particular path passes the rule collection.

As you describe it, it seems that the running time for a “tree split” operation should be proportional to the number of paths to be parsed.
Yet, that is not the case.

I was surprised to find out that the Tree Split components were the bottleneck in my definition.

Well … for “reasonable” real-life trees (i.e. with less than, say, 5-6 dimensions) a bunch of slider pairs (and an enum for controlling the indices domain search [per dimension]) can cut the mustard rather more handily than entering {3-666; 8-1234; >67; <23456; 9-239000}