Getting all components and their relationships within Document

Hello,

I am trying to write a C# program (Ideally it would also work without being added as a component to the document) which finds all components within the document and their relationships. After this they get saved to a JSON file. I am a little lost, since I don’t know how to:

  • interact with grasshopper without using components
  • find a component’s name/values
  • find the connections between components
    Thanks

Some hints:

Instances.ActiveCanvas.Document

ghdoc.Objects.OfType<GH_Component>()

component.Name

component.Params.Inputs / Outputs

ghparam.Sources / Recipients

ghparam.Attributes.GetTopLevel.DocObject