Instantiate components from GH assembly files

I want to instantiate components on the canvas with C#, as shown in this article: Instantiate new Grasshopper objects automatically with C# - James Ramsden

I can instantiate components in the Grasshopper.Kernel.Special and Grasshopper.Kernel.Components namespaces, which includes things like number sliders and the tree operations. However I don’t know how to instantiate components from GH assembly files like CurveComponent.gha which presumably contains components like Interpolate, Divide Curve, etc.

Is there a way to instantiate components from those assembly files?

Hello @DavidRutten sorry to bother but do you think this is possible? Perhaps it is not because the components in the GHA files are not exposed in the Grasshopper API?

Yes it is definitely possible, but does it make sense?!

Anyway all components have a common base (I think its GH_Component) and this base implements the IGH_DocumentObject. The inheritance is very deep in GH, which makes the architecture of GH controversial. Because deep inheritance almost always obfuscates. But the GrasshopperDocument.AddObjects(…) accepts any object implementing IGH_DocumentObject. So not only components, but also other draw-able objects such as scribbles etc… In C# even if a class would be marked as non-public you can instantiate it using reflection, but I think all the components are public. You just need to identify them… I will not motivate you to decompile the sources, but its the most straightforward way to understand the architecture of GH and to detect the components inside the libraries. But you can also simply use the autocompletion or the api documentation to find it. If the script doesn’t load the dll/gha’s you need to add them explicitly. Not sure about this, since I always did similar things on plugin, not scripting level.