Hi Giusseppe,
Good news, you don’t need GhToGhx or windows for this. Rhino 8 for Mac ships GH_IO.dll and the ScriptEditor can batch read your gh files directly — no conversion needed.
Every object placed in a gh file is stored with its component GUID and Name, so a script can scan hundreds of files in seconds without opening them in Grasshopper. This works even for plugin components you don’t have installed.
Open Grasshopper once so the libraries are loaded, then run this in the ScriptEditor (Python 3). Set your folder and the component name (or GUID) at the top:
#! python 3
import os, clr
clr.AddReference("GH_IO")
from GH_IO.Serialization import GH_Archive
folder = "/Users/you/gh-files" # top folder, searched recursively
target_name = "Voronoi" # component name to look for...
target_guid = "" # ...or paste a GUID here to search by GUID instead
hits = 0
for root, dirs, files in os.walk(folder):
for f in files:
if not f.lower().endswith((".gh", ".ghx")):
continue
path = os.path.join(root, f)
archive = GH_Archive()
if not archive.ReadFromFile(path):
print("could not read:", path)
continue
objs = archive.GetRootNode.FindChunk("Definition").FindChunk("DefinitionObjects")
if objs is None:
continue
found = 0
for i in range(objs.GetInt32("ObjectCount")):
obj = objs.FindChunk("Object", i)
if obj is None:
continue
if target_guid:
if str(obj.GetGuid("GUID")) == target_guid.lower():
found += 1
elif obj.GetString("Name") == target_name:
found += 1
if found:
hits += 1
print(f"{path} — {found}x")
print(f"\n{hits} file(s) contain the target component")
If you still want ghx files to text search, the conversion is the same library — drop this in the loop instead and you’ll get a .ghx next to every .gh:
archive = GH_Archive()
if archive.ReadFromFile(path):
with open(path + "x", "w", encoding="utf-8") as w:
w.write(archive.Serialize_Xml())
For your GUID question — no need to dig through files, you can ask Grasshopper directly:
import Grasshopper
for proxy in Grasshopper.Instances.ComponentServer.ObjectProxies:
if "voronoi" in proxy.Desc.Name.lower():
print(proxy.Desc.Name, proxy.Guid)
GUID is the safer search key since names aren’t unique across plugins, but the Name stored in the file is the component’s proper name (not your nickname), so a name search is fine for the built-ins.
One caveat — the search script only sees top level objects, components inside clusters won’t be found. If you use clusters heavily the ghx convert + text search route is the more thorough one.