I’ve finally been getting the hang of manipulating data tree structures --but recently came up against a problem that I just can’t quite seem to come up with a solution for:
Given a list of 50 points on a line some sets of points are removed from the list --in this example the three “chunks” of points removed from the list are:
{1 to 11}
{25 to 37}
{47 to 49}
I want to draw a polyline between the remaining consecutive sets of points… so in this case one line connecting {12 to 24} and another line connecting {38 to 46}.
This is an example --in my application the line may be a more complex curve, and points may not be spaced at regular intervals… and there may be more more less chunks removed with variable numbers of points in each chunk… therefore I can’t use a geometric solution (like measuring between points).
I think it could be done by finding the gaps in the consecutive branch numbers… or maybe theres a better way? Anyone have any suggestion on this? I’ve tried comparing the list of paths with a shifted list of paths… to find where the breaks occur… but keep getting stuck.
Attached file contains the points for polylines the and also a separate list of “chunks” removed (just in case thats helpful)… in this file I just used split tree to manually call up the points I want to make the polylines --just to clearly indicate the desired outcome.
Complex tree management is not much a common thing for me, so by (trying to) helping you i found some interesting stuff!
I found this: https://www.grasshopper3d.com/forum/topics/datatree-selection-rules
(old post, probably we’ve all already seen it, but it’s hard for me to remember the thing correctly…)
1st solution was a workaround flattening the point tree…
2nd solution is actually splitting the tree with a “lexical” mask.
What if he didn’t know the ‘break’ points between chunks though? as a more general problem, lets say you had a large set of points, and wanted to create a tree of lists of points, where each list contains points that have some parameter in common. In Walt’s case, the parameter would be a distance to another point in the list that is less than some threshold value.
I’m dealing with a related issue, except I’m trying to split a list of points into sublists based on their coplanarity. (eg same X coodinate). is there a component that is similar to ‘sort’ in that it takes a list of objects and a list of keys, but instead of sorting them, partitions the list based on key values? (ie anything with the same key ends up in the same list) for an unknown number of common keys?
Hi All! Thanks for all the responses! @Ben4 is exactly correct --the key issue here is that we have a list of a variable number of points with a variable number of chunks removed --and with each chunk for removal containing a variable number of points… so as @Ben4 noted --the only value we can go by is the list order --and looking for gaps in the list branch/list numbers.
Attached here is a kinda ugly solution I came up with --getting paths, comparing the desired branch value to shifted lists of the same brach values (shifted +1 and -1) gives us all the places where the “chunks” of removed points start and end. Then use these points to shatter a polyline made from all the points… split tree the shattered line segments to select only even branches {0,2,…}
There’s probably a more elegant solution to be had --but this at least gets it done… anyone think of something better?
I’ve seen some good posts on this topic already, but thought I would throw in my two cents. I work a fair amount with complex data tree management and have found that TreeFrog is absolutely essential in my workflow. @Ben4 mentioned wanting a component that can partition based on key values, which is what the GraftByData component of TreeFrog does.
Using that, I put together a solution based on the information that you gave. I also created a simpler solution to extract sub-curves based on a theoretical list of Boolean values (I assume you have this but just didn’t include it in the discussion file). Either way, hopefully this is useful.
@rtstangl --thanks for your input! I really wish I could use tree frog --it looks super useful! Unfortunately I’m running Rhino for Mac… which tree frog doesn’t support ;(
I’m considering getting a windows partition with bootcamp going on my mac just to have access to more grasshopper plug-ins!