Retrive geometry list from each IGH_Param Params.Input[0].Source[i]

When one input of a component is getting data from multiple components, how to differentiate which geometry data is coming from which component.

I mean elements of each source from Params.Input[0].Source[0] need to be retrieve.
I have IGH_Param list Params.Input[0].Sources
Now I want to retrieve GH_Goo (geometry objects) from each source(input components). What is the method for getting each element from source [i] ?

for (int ii = 0; ii < Params.Input[0].Sources.Count; ii++)
Params.Input[0].Sources[ii]… ? what is the method which will give me the geometry elements as a list from each input component ?

That’s not possible. Data from all sources is merged inside the input parameter of your component and the associated source is not stored anywhere.

You could theoretically figure it out because the sources are merged in the same order in which they are defined, so you’ll have to determine for each branch in the datatree what range of items came from source X, but it’s tricky and may not be reliable.

1 Like

Many thanks David !

Dear David, I do not see anything wrong in the code below, but I am not able to assign the GH_Curve ReferenceIDs in a tree. I have two or three or more branches, but it is showing branch number zero, if you see the result below. It is able to get all guids of curves but not the tree braches. Which curves are from which branch, is not retrieved. Please modify this bit of code, so I will know what is wrong here. I tried several other way, in each process, the tree data is not retrieved with it’s branches and subbranches. Looks like I am missing something… Many thanks in advance.

** The question is, why I want to re-assign the tree data in another tree. I tried to retriev data from the input tree, in different ways, every time each branch data was missing. All data came under one single branch.

So trying to re-assign and see what is going wrong.

if (!DA.GetDataTree(0, out curvegh)) return;
for (int i = 0; i < curvegh.PathCount; i++)
int countn = 0;
foreach (GH_Curve item in curvegh.Branches[i])
if (item == null)
GH_Path path = new GH_Path(i, countn);
Curve_Guid_list.Add(item.ReferenceID, path);
countn = countn + 1;

0. ea7360c1-de86-425c-b1a3-f56bf3e6c9bd
0. 77910af9-fe94-4519-ad6d-241f4782d9e8
0. 99fb49c3-6600-4d45-871d-52de63e86acf
0. a8a45f98-aab6-4f35-a349-9466f56fc197
0. 5f57c895-fa3e-41e4-93f1-b2916236669d
0. e2e2634f-4ea2-4de8-8b73-3b929e55405d
0. 2b538505-a766-4081-81b2-cde389559d1a
0. 20995afe-842f-4749-abbe-0d722ccfde19
0. 508366c1-f4fb-4813-baae-31f1f96187e2
0. 4170336e-b358-42a2-84d6-a90d11df4ed5
0. ab463a08-bd77-4ec5-83b8-d27572e9c47f
0. bc300e23-0635-465c-82de-4e4f08c3bcd6
0. 5b2657ab-3a31-4fcc-8cee-8cc25eaf4fa9

Here input parameter is as below

protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
pManager.AddGenericParameter(“Curves tree_data”, “tree”, “tree data”, GH_ParamAccess.tree);


Since you didn’t include the variable declarations I can’t be sure of the type of curvegh, Curve and Curve_Guid_list*, but I assume this code is functionally similar to yours, or at least what you intended:

protected override void SolveInstance(IGH_DataAccess DA)
 GH_Structure<GH_Curve> curveTree;
 List<Curve> curveList = new List<Curve>();
 Dictionary<Guid, GH_Path> guidDictionary = new Dictionary<Guid, GH_Path>();

 if (!DA.GetDataTree(0, out curveTree)) return;
 for (int i = 0; i < curveTree.PathCount; i++)
   List<GH_Curve> branch = curveTree.Branches[i];
   for (int k = 0; k < branch.Count; k++)
     if (branch[k] == null || branch[k].Value == null)


     // This will blow up if you try to add the same ID more than once.
     guidDictionary.Add(branch[k].ReferenceID, new GH_Path(i, k)); 

I don’t see a mistake in this code, it should iterate over all branches, and then within each branch iterate over all items. Whether or not the result is correct is impossible for me to verify as I don’t know what to compare the result against.

  • As a general rule it helps to pick one naming convention and stick to it.
1 Like

Ah, I just realised that Curve_Guid_list is also supposed to be a data tree?

1 Like

Many Thanks David ! This is what I was looking into. Looks like using Dictionary is very efficient !

Yes. Curve_Guid_list is a tree.

Best regards.


Dictionary is just a way of storing data but quite intelligent way and very useful. I will use it a lot from now on.
Many thanks David !.

I understand you cannot say what was wrong, because I did not post whole code here.
But still I am looking into the code I wrote ebove was not getting the path of each sub branch ? if there is nothing wrong in my code, it should show the path of each curve as a tree. But it is giving 0 at first branch of the tree all along. It is showing a
flat data, if you see the result I have showed in my second post in this page. Do you know, what was wrongly stored in Curve_Guid_list
DataTree in the second post I had made. I could not find my fault yet, that it was giving wrong result.

I could do something wrong in other part of the code, but not able to see anything wrong.

I will use Dictionary now and will see if it gives correct result, if not then there is some other problem in my code

I only assumed you used Dictionary<TKey, TValue> because that was consistent with Add(item.ReferenceID, path), but there are many types that would be consistent (SortedDictionary, SortedList, GH_Structure, …)

If {0;0}, {0;1}, {0;2}, {0;3}, … is wrong, what is it supposed to be? How many paths are there in curvegh and what do they look like?


OK I just found why it was showing {0,1} {0,2}{0,3}{0,4}…{0,5}{0,6}{0,7}{0,8}
curvegh.Branches.count does not recognize the input component number for
input. We can have multiple input components in one input. But that
information is not the part of the curvegh.Branches.count.


and curvegh.Branches.count=1, this is why

the tree was showing {0,1} {0,2}{0,3}{0,4}…{0,5}{0,6}{0,7}{0,8}
if I have two input components and each containing 4 curves then the tree should look like
{0,1} {0,2}{0,3}{0,4}…{1,1}{1,2}{1,3}{1,4}

If you see the head line of my post, I wrote:
IGH_Param Params.Input[0].Source[index]

all I understand curvegh.Branches.count could not recognize input-component number.
the tree Curve input is not actually stored based on input-component
number . It is a tree but it is considering multiple input-components as
one whole branch, does not matter, how many input component is coming
into one input.

If I say I have two input components for 4+ 4 curves then the sources should be

IGH_Param Params.Input[0].Source[0]
IGH_Param Params.Input[0].Source[1]
Each source should have 4 curves.
how I can get the curves coming from Source[0] and Source[1] ? Is there
any function which can give which data is coming from source[0] and
which data is coming from source[1] or at list number of data coming
from sources[0] and sources[1]? or at list a way to track them by
indexing ***

See my response from 2 days ago. Once data gets merged from multiple sources, there’s no way to figure out what item came from where, short of unpeeling the merging logic which will be difficult and might not be reliable.

If you want to distinguish between data coming from different sources, I recommend using different inputs so everything stays nice and separate.

1 Like

Many thanks ! Yes you told me. Then I could not understand it properly.
Now it is crystal clear !

Best regards