Duplicate entire tree

I’m trying to brute force a solution to a problem where I want to make a curve of a fixed length and have it constrained by two angles at each end of the curve. To achieve this, I’ve chosen the Tangent Curve block.

For my problem, this works in the way where I’ve fixed one of the end points (End Point A), and I move the other end point 1mm at a time to make somewhere in the range of 1000 End Point Bs. I then give the desired tangents to each set of end points, and look at the Length output of the Tangent Curve block, and select the one curve that is closest to my desired curve length [1].

The issue arises when I try to use this to create multiple output curves [2] based on multiple starting angles. i.e. it only works when I provide it one pair of tangents that it matches with each 1000 pairs of end points.

A solution to this in my mind, is to simply duplicate the entire tree of points (for a range of 75 tangents, this would be duplicated 75 times, making 75,000 pairs of end points… hence the brute force). I.e. currently the points are in a tree structure {A}, where A is from 0->1000, but I would want it in a structure {A;B}, where A is 0->75, and B is 0->1000. I would then provide each of the 75 lists of lists to each 75 pairs of tangents. From this notation you probably can tell that I tried path mapper, but failed to really make it work well.

I have no idea if any of this has made sense… because I’m finding it hard to even understand the tree/data management in my own head, so hopefully please just ask questions and I will clarify.

duplicate_tree_example.gh (22.0 KB)

[1] I realise this is inefficient and could probably be solved better with Kangaroo or similar, and I welcome suggestions for how to best solve this problem, but that is not the main point of this thread.
[2] The reason I want to do this for a range of angles/tangents is because this is for programming a robotic arm, and I want to control the motion in between the starting point which would be a flat piece of wood, and therefore I need all the tangents and end points.

Have a look at this:

duplicate_tree_example_re.gh (22.3 KB)

-Kevin

Thanks Kevin, this works, thank you!

I’m now having a bit of trouble getting the output structure exactly how I need it for downstream processing. I can split the curve output into the branches I want using these methods, but they have a weird output where the first and last branches seem to have their indices split amongst them? I.e. they should all be length 1001.

duplicate_tree_example_2.gh (24.3 KB)

Something like this?
I assumed your “1001” value came from the range earlier.
It’s always better to reuse the same variable than duplicating one (ex when you were writing it manually in a path mapper). Means easier code maintenance :slight_smile:

duplicate_tree_example_2.gh (22.6 KB)

ps: Don’t hesitate to send smaller examples, your file took 2 minutes to open !

Sorry, yes you’re right I should have supressed that Replace component!

Hmmm, I agree that what you’ve provided is indeed {A;B}, where A is 0->75, and B is 0->1000, But I think what I meant was {A}(i) where A is 0->75, and i is 0->1000*. So I’m basically there already with the Path Mapper and Replace approach, but for those first and last branches that have weirdly been split in two.

Definitely agree that I want the 1001 to come from a List Length component like you suggest, but right now the Path Mapper works much faster than the Replace approach, but I don’t think there a way of getting an input like that into the Path Mapper block?

Try remove the graft I did on the output of the component… would that be it?

You should be able to accomplish this with a Partition List component and maybe a Flip Matrix component.

You don’t need a List Length component. You allready have the length at the C ouput of the Tree Statistics component.

This will give you a DataTree with 1001 branches and 76 items on each branch:

duplicate_tree_example_2_re01.gh (23.7 KB)

You can eliminate the need for the Flip Matrix component by reversing the inputs and outputs of the Cross Reference component and using the C output of the lower Tree Statistics component as the S input to the Partition List component (again 1001 branches each with 76 items):

duplicate_tree_example_2_re02.gh (22.5 KB)

Here’s a simplified file where you can see the effects of these operations:

CrossRef_Partion_Flip.gh (16.4 KB)

Edit: This is why you were getting an extra branch when using Path Mapper:

I prefer to use the Partition List component because it will adapt if you increase or decrease the amount of data.

Also, as you noticed the Replace Paths component gets painfully slow when working with large amounts of data like you have here.

-Kevin