I made CommandLine a tool for converting Grasshopper files (.gh) to xml (.ghx) with the option to compress the xml file to GZip. In this way the gh files can be made “searchable” (converting entire folder structures in one go). This tool has proved to be useful for me and I thought I’d share the tool with the community, including sources. (download links below)
Ghx files (xml) are suitable for storing in version control systems (VCS) and DIFF tools can spot differences between versions. Some search tools can scan zipped files directly (for example Powergrep), and therefore I added a command to GZip the xml files as well (the tool’s commands operates recursively on folderstructures starting from a folder provided as a first argument when starting the program)
The latest release of a compiled exe file can be downloaded [edit:] from BitBucket Downloads page
-----------------------------------------------------------------------------------------------------------
Howto: Drop the file anywhere on your harddisk, and remove the file extension (it’s a fake extension), and also place your own copy of the file GH_IO.dll in the same folder as the exe file, and then it should simply work). The source files are available at Bitbucket GhToGhx.
-----------------------------------------------------------------------------------------------------------
The tool can also be used interactively (pictured), or called from a batch script, see example bat-file here below (again, remove the fake .txt extension. Also replace all the paths inside the bat-file with your own):
batchrun_ghtoghx.bat.txt (1.7 KB)
Fig 1. Command Line options always shown. More info and screenshots will soon be uploaded to Bitbucket GhToGhx (The info there is not updated, but will be soon):
See also a previous post on the subject:
Batch Mode
Below a list of commands that can be run in batch (or manually via the Console as pictured above). What it does; It:
-
Converts all .gh files in a specified folder - and its sub-folders - to ghx format and places them in a temp folder (…\_ghx) under respective file’s path. (cmd X)
This folder can then be removed if the ghx file isn’t needed anymore (cmd R).
If the .gh file has a twin .ghx file it will not be converted, nor does the Remove R command touch it in any way. -
Compresses all .gh files in a given folder - and its sub-folders - into GZip format (filename .ghx.gz) and places them in a temp folder (…\_gzip) under respective .gh file’s path. (cmd Z)
This folder can then be removed if the ghx file isn’t needed anymore.
The corresponding Remove r command doesn’t touch any other .gzip files than those it has created itself. -
Lists all files and folders and saves the output into logfiles on disk. (cmd g, x, z and d)
-
Deletes all Converted (cmd R) and Compressed files (cmd r) and corresponding temp-folders.
-
Deletes the log files. (cmd C)
REM ---------------------------------------------------------------------------------
REM Prefix “+” means verbose (console display)
REM Prefix “-” means !verbose (no or very little console display)
REM Postfix “L” means = Do log to file
REM g means List regular .gh files
REM X means Convert to .ghx (xml) format
REM x means List ghx files
REM Z means Compress to .ghx.gz (GZip) format
REM z means List compressed files
REM d means List temp directories for ghx and gzip files
REM ---------------------------------------------------------------------------------REM - LOG regular Grasshopper files (.gh)
.\ghtoghx.exe D:\DEV\CAD\GH\GH_Workbench__ScriptComponents\CScriptComponents.ghx +gL
REM - CREATE Xml versions (ghx)
.\ghtoghx.exe D:\DEV\CAD\GH\GH_Workbench__ScriptComponents\CScriptComponents.ghx +XL
REM - CREATE compressed GZip versions (gzip)
.\ghtoghx.exe D:\DEV\CAD\GH\GH_Workbench__ScriptComponents\CScriptComponents.ghx +ZL
REM - LOG ghx file-lists to disk
.\ghtoghx.exe D:\DEV\CAD\GH\GH_Workbench__ScriptComponents\CScriptComponents.ghx +xL
REM - LOG GZip file-lists to disk
.\ghtoghx.exe D:\DEV\CAD\GH\GH_Workbench__ScriptComponents\CScriptComponents.ghx +zL
REM - LOG Ghx and GZip foldername lists to disk
.\ghtoghx.exe D:\DEV\CAD\GH\GH_Workbench__ScriptComponents\CScriptComponents.ghx +dL
REM - REMOVE ghx folders and files (“L” doesn’t play any role here)
.\ghtoghx.exe D:\DEV\CAD\GH\GH_Workbench__ScriptComponents\CScriptComponents.ghx +R
REM - REMOVE GZip folders and files
.\ghtoghx.exe D:\DEV\CAD\GH\GH_Workbench__ScriptComponents\CScriptComponents.ghx +r
REM - CLEAR Log files
.\ghtoghx.exe D:\DEV\CAD\GH\GH_Workbench__ScriptComponents\CScriptComponents.ghx +C?
Let me know if you need more features.
// Rolf