Trouble finding component based on guid

Hi all, I’m trying to find a component by guid. I’ve tried both the GH_Document.FindObject and GH_Document.FindComponent methods, but without any luck. I keep getting null as a result. The weird thing is, when I use doc.ActiveObjects I do see the component listed, and also see that the guid is correct. I’ve also tried Guid.Parse() but also that didn’t work.

The code I’ve tried so far:

Guid SSOID = new Guid("C16886F5-DEF1-4967-BE91-1C31A948480B");
GH_Document doc = OnPingDocument();
var searchResult = doc.FindComponent(SSOID);
DFSSO_Component SSOComp = doc.FindObject<DFSSO_Component>(SSOID, topLevelOnly: false);
var allComponents = doc.ActiveObjects();     

What am I missing here?

See attached (and make it far more elaborated - find options [ObjectType] and/or Layers … etc etc).

GUID_EntryLevel_V1.gh (119.6 KB)

Hi Peter, thanks for your reply. I’m trying to obtain a component of which I know the exact guid.

I’m not doing this within a C# script on the canvas, but in a .gha. I see your solution lists all the guids of objects on the canvas, and finds objects in the Rhinodoc object that belong to that guid.

However, I’m trying to use the GH_Document instance to locate the component. I see it has the method FindComponent, which takes a guid as input. However, I cannot seem to get it to work by defining the guid. Do you know what I’m doing wrong? My feeling is I’m not defining the guid in the correct way.

Well … I have no experience with GH_xxxx Classes/Methods because I never use them. So I have no idea what the GH_Document Class is nor what the Methods do.

But I guess that if the FindComponet(guid) returns bananas the guid is rather wrong.

Anyway: tried (my nerves ARE broken - level of proper documentation [Say: like the one found in Generative Components - my game] is rather MIA) this:

are you using instance guid or component guid?


the find method only works for instance guid.

1 Like

Well … get this as well:

GUID_Comp_EntryLevel_V1.gh (119.7 KB)