GhFileAnalysis 1.0.0
Starting with a -beta version and providing a place to collect feedback on GitHub
dotnet add package GhFileAnalysis --version 1.0.0
NuGet\Install-Package GhFileAnalysis -Version 1.0.0
<PackageReference Include="GhFileAnalysis" Version="1.0.0" />
<PackageVersion Include="GhFileAnalysis" Version="1.0.0" />
<PackageReference Include="GhFileAnalysis" />
paket add GhFileAnalysis --version 1.0.0
#r "nuget: GhFileAnalysis, 1.0.0"
#:package GhFileAnalysis@1.0.0
#addin nuget:?package=GhFileAnalysis&version=1.0.0
#tool nuget:?package=GhFileAnalysis&version=1.0.0
GhFileAnalysis
GhFileAnalysis is a .NET 7 single-file console and library project for reading and writing version information in Grasshopper .gh and .ghx files. It automates and standardizes the management of version metadata in Grasshopper workflows, especially for teams and CI/CD pipelines.
Project Background & Evolution
This project originated from the need to programmatically inspect and update the "version" panel in Grasshopper files, a common practice for tracking definitions in computational design workflows. Early solutions were based on manual editing or ad-hoc scripts, but these approaches were error-prone and not easily automated.
The codebase evolved by:
- Studying community scripts (notably by David Rutten and Andrew Heumann) for safe manipulation of GH_IO chunks.
- Experimenting with the GH_IO API to ensure compatibility with both legacy and current Grasshopper file formats.
- Refactoring into a reusable service (
GhVersionService) and a robust CLI, supporting both interactive and non-interactive (pipeline) use. - Implementing true single-file deployment by embedding and dynamically loading
GH_IO.dllat runtime, so only one executable is needed.
Current Capabilities
- Read the version from the first panel with NickName
"version"in a.ghor.ghxfile. - Set or update the version in that panel, or create it if missing.
- Interactive console mode for manual workflows.
- CLI mode for scripting and automation, with clear exit codes for integration.
- Reusable C# API for integration into other .NET projects.
- True single-file deployment: all dependencies, including
GH_IO.dll, are embedded and loaded at runtime. - Windows support (due to GH_IO dependency).
Usage
CLI
Print the version from a .gh or .ghx
file:GhFileAnalysis.exe path/to/file.ghxGhFileAnalysis.exe path/to/file.ghPrint the version (alternative syntax)GhFileAnalysis.exe -v path/to/file.ghxGhFileAnalysis.exe -v path/to/file.ghSet the version in a .ghx fileGhFileAnalysis.exe path/to/file.ghx -v 1.2.3GhFileAnalysis.exe path/to/file.gh -v 1.2.3
Interactive
Run without arguments to enter interactive mode. You can:
- Enter a file path to inspect.
- Use
-vto print the version. - Use
-v <version>to set the version. - Type
xto exit.
As a Library
Reference GhVersionService in your own .NET project:
using GhFileAnalysis;
string? version = GhVersionService.GetVersion("path/to/file.ghx");
bool ok = GhVersionService.SetVersion("path/to/file.ghx", "1.2.3");
(Works for both .gh and .ghx files.)
Implementation Details
- Single-file deployment is achieved by embedding
GH_IO.dllas a resource and extracting/loading it at runtime using a custom loader (DllResourceLoader). - No extra files are needed at runtime; just distribute the single
.exe. - Assembly resolution is handled so that
GH_IO.dllis found and loaded even when extracted to a temporary location.
Where It Still Needs Work
- Panel search is basic: only the first
"version"panel is read or written; multiple panels are not handled. - No backup/undo: Overwrites files in place; consider versioning or backup strategies for production use.
- Limited error reporting: Some edge cases (e.g., malformed files) may not provide detailed diagnostics.
- No advanced metadata: Only the
"UserText"field is managed; other panel or document metadata is not exposed. - Windows only: Due to the GH_IO dependency.
Contributing & License
This is a beta version and as such comments, suggestions, and bug reports are welcome.
- Currently, the code is not open for contributions, but this may change in the future. Licensed under the MIT License.
Credits
- Inspired by scripts and advice from the Grasshopper community
- especially David Rutten and
- Andrew Heumann
- Uses GH_IO.dll for Grasshopper file access
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net7.0
- Grasshopper (>= 8.20.25147.11001-rc)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|