Finding External Nodes/Libraries Inside Clusters - python

I’m trying to write a GhPython script that inspects all components in a Grasshopper definition including inside clusters (and nested clusters) to find which external (non-core) assemblies and nodes are being used.

I tried with isinstance(obj, Grasshopper.Kernel.Special.GH_Cluster but no luck

Any working example or reference would be greatly appreciated!

Currently only works for the top-level Grasshopper document
list_external_plugins.gh (6.7 KB)

I don’t have time to test this right now, and I don’t know how to adapt it to search inside clusters, but to find the plug-ins files for normal GH components on the canvas, from an IronPython component (I use the old GhPython ones), I think you can work this out from the .FilePaths of everything in Grasshopper.Kernel.GH_ComponentServer().ExternalFiles(True, True), and filter out anything that’s an internal core assembly e.g.

gh_comp_server = Grasshopper.Kernel.GH_ComponentServer()

paths = [file_.FilePath for file_ in gh_comp_server.ExternalFiles(True, True)]:

I wrote similar code to find an external plug-in’s own .ghuser files, and so locate the Python package that should’ve been installed alongside them (to temporarily add that to sys.path and import it). It helped me relax the strict installation instructions, users previously had to follow.