Grasshopper

algorithmic modeling for Rhino

Well... it failed.

I have a list of paths that I split before the file extension. Now I want to get a list with only item "0" which is the path without the extension.

My mask gives me exactly what I don't want : the extension alone.

Later, I figured how I could do what I wanted with "Flip" plus "Branch", but that leaves me just as ignorant about path mapping and why my attempt failed.

Views: 2277

Replies to This Discussion

Hi Olivier,

are you trying to get this done, or are you trying to learn how to use the Path Mapper?

If (A), then just use the List Item component with the index set to 0. Or use the Cull Index component with index set to 1. Or replace the text ".csv" with an empty text before splitting the file paths.

If (B), then this is a weird problem for the path mapper to do. The mapper was designed to transform a tree from one topology into another, without removing any of the items. It is possible to 'lose' items in a path mapper, chiefly because it's possible to overwrite items, which is what's happening in your case. Let's walk through it. Here's what the mapper does, step by step.

I recreated your problem with easier data, so we can be clear exactly which item we're talking about:

  1. The path mapper detects that you're using index notation on at least one side of the mapping (i.e. the (0) bit at the end of the target map). This means it'll iterate over all the items in the tree, rather than treating lists whole.
  2. So it starts by looking at the first item in your tree, which is "Lemon" at {0}[0]. It loads the value 0 into your variable 'A'. The second zero (the item index) doesn't get loaded anywhere because your source map looks like {A} rather than {A}(i).
  3. Then it looks at the target map and it puts "Lemon" into the new tree at location {0}[0] (which is the exact same location as before).
  4. Next it looks at the second item, which is "txt" at {0}[1]. It too goes into {0}[0], where it overwrites the "Lemon" text that was already there.
  5. This pattern repeats itself. "Lime" gets stored at {1}[0] in the new tree, only to be overwritten immediately afterwards by "csv". "Orange" gets stored at {2}[0], only to be overwritten by "dxf". etc. etc.

So every extension overwrites its respective citrus, because they are both stored at index=0.

In short, the Path Mapper is not the tool to use to select specific items from a tree, it's only good at transforming entire trees.

Incidentally the [Split Tree] component which uses a notation somewhat similar* to the Path Mapper does do what you're after. It's purpose is to take a tree and split it into two separate, but topologically identical trees, where each item in the original tree only occurs in one of the outputs. Namely, if the item is described by any of the splitting masks, it'll end up in the P (for positive) output, if none of the splitting masks describe the item location, it'll end up in the N (for negative) output:

Attachments:

Oh thanks ! Now I know "Split Tree" !

I would love to see little screen captures like this in the "Grasshopper Help" boxes.

If I look into the present Help for "Split tree", it will mention "Splitting Masks" , and up to now, in my mind, it would only bring this up.

:)

Yeah we're working on a better help system for GH2, with proper explanations and example files for all components. But ---like GH2 itself--- it's a long term project.

List item... of course !

Duh... I use this all the time ; why did I start messing with the Path Mapper ?

I guess read the "Help" text for Path Mapper and found : "Take the original path but ignore the last index" ; and it sounded close to what I was trying to do.

Now I'm trying to flip all the matrixes in these .csv files , but all at once , since I could have dozens of them.

I understand that "Flip Matrix" can't handle this because he wouldn't know what branches to flip.

Would the Path Mapper help me here ?

Is there a "Path Mapper for dummies" book that I could read ?

The primer / Third edition is a bit abrupt on the subject.

I found a "PathMapper_20110315.png" image but it just stacks examples and somehow doesn't give me the key.

Cheers,

YES, the path mapper may be of help here.

There's no consolidated tutorial anywhere as far as I'm aware, just a bunch of people who wrote some stuff about it. However by and large the path mapper is conceptually easy to understand, the difficultly is in coming up with the exact mapping you're after, which is more a datatree problem than a mapper problem.

The bit on the left (or the "source pattern") must match the datatree you have. If your tree consists of {0}, {1}, {2}, etc. then the pattern must look like {A}, or optionally {A}(i) if you also with to take the item index into account. That's the easy part, and you can use the 'Create Null Mapping' menu option to generate correct source patterns.

The bit on the right (or the "target pattern") is what you want the tree to look like. In your case you wish for the last path element and the indices to be switched. So a tree that looks like {A;B;C}(i) instead becomes {A;B;i}(C). See, you're 'flipping' two parts of the location of each item within the tree. 

Attachments:

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service