# Select multiple data paths permutations

**URL:** <https://discourse.mcneel.com/t/select-multiple-data-paths-permutations/223801>\
**Category:** Grasshopper\
**Tags:** windows\
**Created:** [October 21, 2026, 6:01pm UTC](https://discourse.mcneel.com/t/select-multiple-data-paths-permutations/223801 "2026-10-21T18:01:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Flux](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/flux/32/768127_2.png) [@Flux](https://discourse.mcneel.com/u/Flux)\
**Post date:** [October 21, 2026, 6:01pm UTC](https://discourse.mcneel.com/t/select-multiple-data-paths-permutations/223801/1 "2026-10-21T18:01:18Z")

</div>

![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/b/a/9/ba973c9ea4f3c09edad80b4265fa622ea29d7ce8.png)

[data paths permutations.gh](https://discourse.mcneel.com/uploads/short-url/qrhWlLS3kkRzNhaNg590Mj5koMs.gh) (20.1 KB)  
My question is whether this is possible without using Python. The idea is to have a tree with multiple paths as items where each branch has a permutation of all possible paths minus the current one. From those I want to select paths from another tree. In the other tree are branches with single or multiple items so the result tree should have a sublist. For example all paths with 0 or 1 items should end with “;0” while the ones with multiple items should end with the corresponding item index. Gemini did the python script.

> **python**
>
> import Grasshopper
> 
> from Grasshopper.Kernel.Data import GH\_Path
> 
> from Grasshopper import DataTree
> 
> # Fixed: ‘object’ as a type inside brackets, followed by instantiation parentheses ()
> 
> output\_tree = DataTree[object]()
> 
> if Paths is not None and Data is not None:
> 
> ```
> print("Processing {} paths branches...".format(Paths.BranchCount))
> 
> for i in range(Paths.BranchCount):
> 
> try:
> 
> target_path = Paths.Path(i)
> 
> except:
> 
> target_path = Paths.Key(i)
> 
>         
> 
> branch_paths = Paths.Branch(i)
> 
>     
> 
> for p in branch_paths:
> 
> try:
> 
> \# Clean and parse the path value safely
> 
> if hasattr(p, "Indices"):
> 
> gh_p = GH_Path(\*p.Indices)
> 
> else:
> 
> clean_str = str(p).strip("{}\[\]() ")
> 
> if ";" in clean_str:
> 
> parts = \[int(x) for x in clean_str.split(";")\]
> 
> elif "," in clean_str:
> 
> parts = \[int(x) for x in clean_str.split(",")\]
> 
> else:
> 
> parts = \[int(clean_str)\]
> 
> gh_p = GH_Path(\*parts)
> 
>             
> 
> \# Directly try fetching the branch items
> 
> source_items = Data.Branch(gh_p)
> 
> if source_items:
> 
> for item in source_items:
> 
> output_tree.Add(item, target_path)
> 
> except Exception as ex:
> 
> pass
> 
> ```
> 
> a = output\_tree

Thank you in advance!
