I am currently creating a custom component and want to automatically connect it to another one of my custom components (CompB) if that component exists on the canvas.
CompB is unique on the canvas and will not have a duplicate of itself.
I understand I need to get the GH_Component, but I can’t quite find the correct method.
Hi @christopher.ho
you had to cast obj
to IGH_Component
public override void AddedToDocument(GH_Document document)
{
Guid guid = new Guid("");
for (int i = 0; i < document.Objects.Count; i++)
{
if (document.Objects[i].ComponentGuid == guid)
{
IGH_Component comp = document.Objects[i] as IGH_Component;
this.Params.Input[0].AddSource(comp.Params.Output[0]);
break;
}
}
}