# Path problem

Hi Community,

I have two paths I need to apply a component (surface closest point) to, but the path is confusing me. Could you help me please?

Points:
{0} x points
{1} y points

Surfaces:
{0} z surfaces
{u} u surfaces

What I want is:
On branch {0}, for each of the x points, I get Surface_closest_point(this point, each of the z surfaces)
On branch {1}, for each of the y points, I get Surface_closest_point(this point, each of the u surfaces)

Thanks a lot

I tried grafting Points, Surfaces, or both. None has worked so far

This is doable with data duplication, but Iâm wondering if itâs possible to do without

Not sure I followed, and you didnât post files - check this to see if it helps:
ex.gh (10.9 KB)

1 Like

this is another way, the data structure you get is like:

`{a;b} (i, i+1, i+2...)`

where:

``````a = original Point tree path
b = index of Point in original tree path {a}
i = closest point to original Point {a} (b) on surface at {a} (i)
``````

With_Data_Duplication.gh (22.6 KB)

2 Likes

1 Like

Thanks so much for your help RenĂ© and inno, I learnt new functions Entwine, Bang! (only knew to use them for kangaroo solver before), and Ungroup (I was duplicating the path âindicesâ and tree-branch-accessing my data, which I think is path-dependent and more verbose).

The duplication method reminds me of some matrix computation tricks. I wonder if the data is actually being duplicated fully (taking more space), or there is some background optimization such that only a âviewâ of the data is used!

I guess Duplicate Data only references the very same data again, so it doesnât create a bottleneck itself, but as soon as that duplicated data gets some sort of manipulation then you get a âreality checkâ

there are always multiple ways to get to the very same result, sometimes itâs important to ask ourselves if a given data tree -that might be absolutely correct from a âdata flowâ point of view- is also the most convenient solution for the next computational step

in this particular case of your with points and surfaces, I think I would consider how many main branches of points and surfaces are there on the starting data treeâŠ because for sure you can bang and entwine stuff to get the very same identical output as for Duplicate Data, but that can work if you have a ârelatively smallâ amount of branches

so you can decide to bang/entwine if you have like2, 3, 4 up to 10 branches (well 10 itâs already a good number of clicksâŠ) but if you have like 1325 branches then bang/entwine is not really a thing to consider (âŠI have seen thingsâŠ)

another question might be if your starting data tree in this example is subject to changes, you donât want to find yourself having prepared a very nice definition that works perfectly for 12 branches, but wonât work on 20 branches

so itâs more a matter of evaluating the best option for the task youâre up to

1 Like

Thanks very much for your super-detailed explanation into! Iâm in a multi-surface-and-multi-points situationâ

Iâm trying to obtain the subtracting body that would create the shell of a larger body, given that larger body and its shell (we have trouble shelling a complex body thatâs complex due to combining a ton of simple bodies; the good news was a divide-and-conquer works!)

âand the former (Group-Ungroup) seems like the way to go!

Previously, I have caveman-ed by duplicating the same code for each additional can-be-done-at-same-time-as-the-previous operation on the code and had a prehistoric time editing each copy every time I need to do so for one of them!

1 Like

we all have been in that spot and for sure Iâve been there for much more time than the average user keep up the good work

1 Like