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.
The Addon manager lists used addons and information about them, like the used version
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: