Dear Path Mapper,

Why couldn’t you be made more versatile ?
I naively assumed that you could double as a “Replace Path” alternative if, instead of using letters and wildcards, I used actual path numbers.
But no : you just stack my lists into each branch of the new tree :

One could also argue that the “Replace paths” could be made to work like a path mapper if it accepted letter placeholders and wildcards, but with the added bonus of having a dynamic input.

In short, I find that these two tree management tools could be advantageously combined into one, and I certainly am more interested in what GH2 has in store in that area than in the color picking business.
IF you see what I mean.

Look closer.
My mapping cannot be described like this.

Oh. I assumed that there was a pattern, otherwise there is no point in using that component, it was not designed to change paths by hand, but to do it with a grammar.

My argument is that it could do both, and also get better by making the pattern definition dynamic.

That’s like developing the math for counting with the fingers.

I totally agree, however, this way we can dynamically change Path Mapper:

PathMapper.gh (16.7 KB)

It only takes 3 lines of code to implement Path Mapper with dynamic input but as @Dani_Abalde mentioned it’s not the way it supposed to work.

private void RunScript(DataTree<object> data, string source, string target, ref object A)
  {
    DataTree<object> treeOut = new DataTree<object>();
    GH_Lexer.PerformLexicalReplace<object>(new GH_Lexer(source), new GH_Lexer(target), data, treeOut);
    A = treeOut;
  }


DynamicPathMapper.gh (17.9 KB)

I work with ShapeDiver, so it can help to keep my files free from scripts. I made a simplified version of Path Mapper that’s able to take the “ * “ wildcard with only Grasshopper components.

It only handles paths symbolically, so denoting a Source Path as {0;1} is treated the same as denoting it as {a;b}. The wildcard captures any depth of branch not captured by the other symbols. For example, I can swap the last branch indices of a tree of depth {0;1;2;3;4;5} by mapping from {*;a;b} to {*;b;a} or even to {b;*;a} (which would put the branches on {4;0;1;2;3;5}).

It’s basically useful whenever the exact depth of the tree is not known/can change, but it is known where the branch depths of interest are relative to the start or end of the depth.

I hope that makes sense, and that it may come to be useful to someone!

P.S. It’s relatively fast, but the main bottleneck lies in the “Replace Paths” component that it uses. If someone knows a faster way to place items from one branch onto another, I’m keen to find out!

Dynamic Path Swapper.ghuser (21.4 KB)

dynamic path swapper example.gh (33.7 KB)