What is in path component?


Something I cannot find explain. The first Replace component running much slower than the second one. Does anyone know the reason?

Many thanks.

what is the secret in path component.ghx (125.5 KB)

The C# component outputs a list of Text so the Replace components must somehow convert this Text to Path:

You can simply use a Path parameter to convert these data before using Replace.

1 Like

how to access or produce “path” in C#?
What is “path” if it is not string?

var path = new GH_Path(i, j, k);
tree.Add(new GH_Integer(1000), path);

// Rolf

1 Like

Thank you Rolf.
Can you explain the code further? I am new for C#.

In your example you can use something like this:

private void RunScript(System.Object path, ref object A)
  GH_Path p = (GH_Path) path;
  A = p.PrependElement(0);

Path.gh (6.1 KB)

1 Like

A path is a custom datatype. You can think of it as an array of integers if you want, but it’s all wrapped up inside the GH_Path class.

You can create a new path using the GH_Path class constructor, or by modifying an existing path, as @RIL showed.

1 Like

Thank you Mahdiyar!

can I retrieve GH_path for a data tree input?

Great discussion. Furthermore, how to access List<GH_Path> or DataTree<GH_Path>?