 # Data Mapping (Small Tree to Large Tree)

Hola!

I have what seems to be a simple data-tree problem.

I have data tree called `Lukes Awesome Data` of `{A;B;C}(i)`, where: `A` are rectangles, `B` is the rectangle faces (either front or back), and then `C` are grouped `points` related to those faces.

For example `{0;0;0}(4)` refers to the first rectangle, on the front-face, with the first group of points (which refer to the four corners of the rectangle). I have five groupings of points per face i.e the `path_count` of `C` is five.

This structure is important to my script, but I quite often break it down to do some transformations and then rebuild it. I’m at a point where I want to assign geometry from a datatree called `Daves Lame Geometry` to these point groupings. `Davids Lame Geometry` contains five different geometry on one branch:

`Daves Lame Geometry`: `{A}(i)` where `item_count` is equal to 5

I would like it to be applied to each of the five paths at the third-level of `Lukes Awesome Data`, i.e.:

`Geometry A` should be applied to all `(i)` points within `{A;B;0}`
`Geometry B` should be applied to all `(i)` points within `{A;B;1}`

`Geometry E` should be applied to all `(i)` points within `{A;B;4}`

Such that `Geometry A` is applied all values across the different branches: `{0;0;0}`, `{0;1;0}`, `{0;2;0}``{0;99;0}`, no matter how many rectangles there end up being.

I thought if I `Grafted` the data in `Lukes Awesome Data` so each point was on its own branch `{A;B;C;i}`, and I remapped `Daves Lame Geometry` to → `{A;B;i}`, that the mapping would assume I want to apply the geometry at that grouping level, rather than the individual level:

`Geometry A` `{0;0;0}` → Point Grouping #1 `{0;0;0;0}`, `{0;0;0;1}``{0;0;0;4}`
`Geometry B {0;0;1}` → Point Grouping #2 `{0;0;1;0}`, `{0;0;1;1}``{0;0;1;4}`
Etc.

In hindsight it was a silly assumption on my part. Instead I am trying to recreate `Daves Lame Geometry` to match `Lukes Super Awesome Data`, which I thought I could do with duplicating the data, so that `Daves Lame Geometry` would look like:

`{0;0;0}` :
`Geometry A`
`Geometry A`
`Geometry A`
`Geometry A`
`{0;0;1}` :
`Geometry B`
`Geometry B`

etc.

But for the life of me I can’t seem to figure out which combination of `Longest List` and `Duplicate Data` to use. `Longest List` seems to work initially, but then doesn’t wrap the way I expect it to. I think others have had this problem too, but I’m not sure if I’m Googling/Searching for the correct terms to bring up any solutions?

Any suggestions would be fantastic!

Thanks,

Luke

So I found a solution using `Duplicate Data to Match` (Dup) from `Elefront`.

.

I don’t quite understand the logic, but essentially it repeats `Daves Lame Geometry` to match the number of branches in `Lukes Awesome Data`, flips the tree from `{A;B;C;D}(i)``{A;B;C;(i)}` (I think it inherits the data-structure from the Length `L` input, hence why its not `{A}(i)` anymore), which is why it needs to be simplified it back into `{(i}}`. From there you can use `Lukes Awesome Data` as a guide input for `Duplicate Data Match`, to correctly duplicate `Daves Lame Geometry` across the indexes of each branch, which is the bit I don’t entirely understand how it works.

It would be nice to know how to recreate the `Duplicate Data Match` without using `Elefront` though, or another solution to this problem (even an explanation for how `Duplicate Data Match` works would be nice!).

Hope this helps somebody!

Luke

1 Like