Understanding old GH code - compare two versions of a GH file

This GH code is more than five years old, since I “completed” it in 2021.


It consists of nine GH files (plus two Hops files) connected by extensive use of Data Input/Output components.

Lately, I’ve been trying to clean it up and make it work again (R7), which is more difficult than you might think. Useful filenames are only one part of the issue, but they help!

This post is about a feature that won’t help me now (even if done for R7, which will never happen).

It has long been standard practice in conventional languages to compare two versions of a file to see specific, line by line differences. As far as I know, that’s impossible in GH (I’ve tried using XML). The ability to do that with GH files would make a world of difference.

Hi Joseph -

One can compare versions in Grasshopper 2.
-wim

All component instances are located in the GH Document. You can either simply print the component list or you even rebuild the execution plan and dump it into a text file. Its a bit tricky to find the most upstream component, from there you can however go through all connections and recursively jump from component to component.

Once dumped into a text file, you could make diff in tool you like.
Such a script should work for various GH versions. I think you just need to be sure you make its deterministic.

Overall it would be a fun scripting challenge.

This doesn’t help when it comes to build maintainable definitions. Which always has been a pain in GH…

When you drag and drop a definition onto the canvas, press E and it opens the definition in a viewer where you can export as *.ghx file

The* .ghx file is basically an *.xml file which can be viewed in an editor which should have an option to compare two files.

Interesting, but that doesn’t do me any good. I may not live that long and, after the R8 fiasco, I’m not likely to pay for anymore upgrades.

Yeah, comparing XML files works but there is a lot to be ignored. “Save as GHX” works fine.

This doesn’t look right… :roll_eyes: Old code is a mess!

Progress! To understand the code and because my GH skills have improved, I rewrote portions of the original GH file (the only one of nine in this project that needed it).

The most difficult part was recreating the “pilot house”, so once I achieved the raw shape, I internalized it and started a new GH file (see cyan group) to make the curved roof (NetSurf) and fillet some edges (FilEdge).


PH_2026Jul12c.gh (50.0 KB)

Most of this code (except the gold group) replaces the flat roof with a curved NetSurf. See Join at the lower right (green group).

The gold group uses ‘Y’ and ‘Z’ coordinates of edge midpoints to select edges for FilEdge. See And (yellow group). This technique might be useful to others?

Done in R7 but probably works in R8. (it does!)

P.S. This is still difficult. The Fuchsia (reddish) colored group at the bottom of this image is the entire code I posted earlier, with some obsolete (I think?) bits deleted. But it’s more difficult than expected to be sure… and to determine what’s next?
:frowning: