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();
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.