A Grasshopper plugin that enables intelligent search for similar component clusters from a local Neo4j graph database. Select components in Grasshopper, and GraphHop2 will find and display similar configurations from your database, allowing you to quickly discover and open related Grasshopper files.
AecTech2025 Hackathon Project
GraphHop2 connects Grasshopper (Rhino's visual programming environment) with a Neo4j graph database containing parsed Grasshopper files. When you select components in Grasshopper, the tool queries the database to find similar component clusters and displays matching files in a popup window. You can then open these files directly with the solver disabled for safe exploration.
- Component Selection Query: Select components in Grasshopper and query for similar configurations
- Exact Match Search: Find files containing identical component connections and configurations
- Fuzzy Path Matching: Discover similar component paths with flexible length matching
- File Browser Interface: Popup window displaying matching Grasshopper files with details
- Safe File Opening: Automatically disables solver before opening files to prevent unintended execution
- Neo4j Integration: Leverages graph database for efficient pattern matching and relationship queries
- Rhino 7+ (or compatible version)
- Grasshopper (included with Rhino)
- Neo4j Database (local or remote instance)
- Neo4j.Driver NuGet package (automatically referenced via
#r "nuget: Neo4j.Driver")
- Install and run Neo4j (Community Edition or Desktop)
- Load your Grasshopper database dump file into Neo4j
- Ensure the database contains parsed Grasshopper files with the following structure:
- Nodes:
ComponentInstance,DocumentVersion - Relationships:
Wire(between ComponentInstance nodes) - Properties:
ComponentGuid,VersionId,FilePath,PivotX,PivotY
- Nodes:
Set the following environment variables for Neo4j connection:
NEO4J_URI=neo4j://[your_connection_uri]
NEO4J_USER=your_username
NEO4J_PASSWORD=your_passwordAlternatively, you can pass these values directly to the Neo4jConnector constructor.
- Clone or download this repository
- Copy the project files to your directory
- Ensure all utility classes are accessible:
SelectionToGraphUtility.csFindPathFromInputToOutput.cs- Other utility classes in the
Utilities/folder
- Open Rhino's Script Editor
- Open project
GraphHop2.rhproj - Run
QuerySelectedGhComponentsFromNeo4j.cs
- Select Components: In Grasshopper, select the components you want to search for
- Run Query: Execute the search script (via C# script component or custom component)
- View Results: A popup window will display matching Grasshopper files
- Open File: Select a file from the list and click "Open" to load it (solver will be disabled)
using (var connector = new Neo4jConnector())
{
var tuples = GetSelectedTuples();
if (tuples.Count == 0)
return;
var generator = new ExactMatchQueryGenerator(connector);
var records = await generator.QueryFromTuples(tuples);
var filePaths = await generator.QueryDocumentVersionFilePathsFromComponent(records);
Console.WriteLine($"Found {filePaths.Count} document versions");
}var search = new Search();
var selectedObjects = Grasshopper.Instances.ActiveCanvas.Document.SelectedObjects();
int score = search.search(selectedObjects);- Manages connection to Neo4j database
- Provides query execution with optional debug output
- Handles async operations and resource disposal
- Generates Cypher queries for exact component configuration matches
- Converts Grasshopper component selections to graph queries
- Retrieves file paths for matching document versions
- Creates queries for similar component paths
- Supports flexible path length matching (min/max length)
- Finds paths between start and end components
- Main search interface combining multiple query strategies
- Implements scoring system for match quality
- Integrates exact match and path match queries
- Provides UI for file selection and opening
- Displays file details (name, modification date, location)
- Handles file opening with solver disabled
ComponentInstance
- ComponentGuid (string)
- VersionId (string)
- PivotX (float)
- PivotY (float)
DocumentVersion
- VersionId (string)
- FilePath (string)
Wire (Relationship)
- Connects ComponentInstance nodes
-
Exact Match Query: Finds files with identical component connections
MATCH (n1:ComponentInstance)-[:Wire]->(n2:ComponentInstance) WHERE n1.ComponentGuid = '...' AND n2.ComponentGuid = '...' RETURN n1.VersionId, n1.PivotX, n1.PivotY
-
Fuzzy Path Query: Finds similar paths between components
MATCH (start:ComponentInstance), (end:ComponentInstance), p=((start)-[:Wire*{minLength}..{maxLength}]->(end)) WHERE start.ComponentGuid = '...' AND end.ComponentGuid = '...' RETURN p
Converts selected Grasshopper components into connection tuples for graph queries.
Finds shortest paths from input components to output components in the selection.
GraphHop2/
├── QuerySelectedGhComponentsFromNeo4j.cs # Main entry point
├── GraphHop2.rhproj
├── Neo4jConnector.cs
├── Test1.ghx #grasshopper test file
├── Utilities/
│ ├── FindSelector.cs
│ ├── FindPathFromInputToOutput.cs
│ ├── SelectionToGraphUtility.cs
│ ├── SelectionToInputUtility.cs
│ └── SelectionToOutputUtility.cs
├── QuerySelectedGhComponent.cs
├── QuerySelectedGhComponentInput.cs
├── QuerySelectedGhComponentOutput.cs
├── QuerySelectedGhComponentToGraph.cs
├── QuerySelectedGhComponentFromNeo4j.cs
└── README.md
- Create a new query generator class (similar to
ExactMatchQueryGenerator) - Implement query generation logic
- Add scoring method to
Searchclass - Integrate into main search workflow
- Verify Neo4j is running and accessible
- Check environment variables are set correctly
- Ensure firewall allows connection to Neo4j port (default: 7687)
- Verify database contains parsed Grasshopper files
- Check that ComponentGuid values match between Grasshopper and database
- Ensure Wire relationships are properly created in the database
- Verify file paths in database are valid
- Check file permissions
- Ensure Grasshopper is loaded in Rhino
This project was created for the AecTech2025 Hackathon.
Contributions are welcome! Please feel free to submit issues or pull requests.
- Built for AecTech2025 Hackathon
- Uses Neo4j graph database for pattern matching
- Integrates with Grasshopper and Rhino