Grasshopper document list external dependencies / installed plugins, 3rd party libraries, version, referenced files

Hello again,

my goal is to document what external dependencies were used for a specific grasshopper document, so the result can be exactly replicated in the future when needed.

Goal:

  • get list of plugins (names) used in the canvaswith version
  • get list of user objects used in the canvas with version
  • exclude preinstalled grasshopper components/plugins

Some of the features are part of the “Pancake” plugin, with the features ‘Portability report’ and ‘Addon Manager’ but these are no grasshopper components and I can’t use them from my gh python component.

2020-11-13 10_00_15-Grasshopper - components
The Addon manager lists used addons and information about them, like the used version

2020-11-13 10_02_51-Grasshopper - components
The portability report additionally lists ‘referenced files’ that are used in the canvas.

Here is a snippet to get the names and types of the used components (from another forum post):

import Grasshopper as gh

names = []
types = []
for obj in ghenv.Component.OnPingDocument().Objects:
    if isinstance(obj,gh.Kernel.GH_Component):
        objName = obj.Name 
        objString = obj.ToString()
        if objName not in names:
            names.append(objName)
            types.append(objString)

With this I still don’t know which components were used, at least not in a stable way. Something like Pufferfish.Components.Components_Point._1_Point.TweenConsecutivePoints indicates that a Pufferfish component is used, but how would I get which version of it was used? It is not in the list of plugins as acquired by the following snippet.

I could use something like

plugin_type = "Pufferfish.Components.Components_Point._1_Point.TweenConsecutivePoint"
plugin_name = plugin_type.split(".")[0]

to know which plugin was used, but what about component types like user objects etc?

Get installed plugin versions (adapted from a forum post)

import Rhino

d = Rhino.PlugIns.PlugIn.GetInstalledPlugIns()
for entry in d:
    plugin = Rhino.PlugIns.PlugIn.Find(entry.Key)
    if plugin:
        assembly = plugin.Assembly
        print(plugin.Name)
        print(plugin.Version)

This only leads to one external / ‘real’ plugin:
2020-11-13 10_24_02-Grasshopper Python Script Editor

Actually the info is saved in each Grasshopper definition. You can inspect the info by FileViewer.

Besides, you can find which plugin a component belongs to by GH_ComponentServer.FindAssemblyByObject

Try to enumerate clusters in the document and check references. Generally the idea is difficult to fulfill because once a user object is added to the canvas, it loses connections with the original GHUSER file.

Start Grasshopper + Pancake with Shift pressed, you’ll see a developer menu entry at the bottom of the Pancake menu. And there’s a “List of core components” and you will get a list with all built-in components. Also you can check the IsCoreLibrary property of a GH_AssemblyInfo, although it’s slightly more complicated to cover all situations.

1 Like

Thanks!

import Grasshopper as gh

asms = {}
for obj in gh.Instances.ComponentServer.ObjectProxies:
#for obj in ghenv.Component.OnPingDocument().Objects:
    asm = gh.Instances.ComponentServer.FindAssemblyByObject(obj.Guid)
    #print(x.IsCoreLibrary)
    if asm is not None and not asm.IsCoreLibrary:
        asms[asm.Name]=asm.Version

print(asms)

Result: {'Pufferfish': '2.9.0.0', 'Human': '1.2.0', 'MetaHopper': '1.2.4', 'GH_CPython': '', 'Pancake': '2.4.0.0', 'Kangaroo2 Components': '2.5.2', 'BullAnt': '', 'NGon': '2.3.0', '.Py Code Reader': '0.1', '': '', 'PlanktonGh': '0.4.0.0', 'Bifocals': '', 'Weaverbird': '0.9.0.1', 'Mesh Pipe': '1.0.0.0', 'MeshEdit Components': '2.0.0.0'}

This works now, but this still prints all versions and not only the ones in the canvas. I tried using for obj in ghenv.Component.OnPingDocument().Objects: but these objects got no Guid.

Do you know a way to use the document objects in the code snipped above?

obj.Guidobj.ComponentGuid

1 Like

That’s it, thank you once again!

Thanks for this thread all of you above.

I’ve made the recommended changes to the code - please find attached.

Cheers

DK
230424_Find Dependencies.gh (9.4 KB)

1 Like

Hello,

I’m trying to limit the amout of dependencies in my scripts and this will help a lot.
Thank you.

My own version list the components and how many times they occur.
You can locate them on canvas using MMB → Find


List dependencies.gh (9.1 KB)