Skip to content

modfivelabs/GhToGhx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GhToGhx is a CommandLine tool which recursively scans folder structures on disk for Grasshopper definition files (extension .gh) with the option to convert them to ghx format. GhToGhx starts scanning from a folder given as the first CommandLine option (a filename or a folder) and optionally a second option for invoke commands (as illustrated below).

GhToGhx also has commands for listing gh and ghx files in addition to the command for converting (binary) gh files to ghx (plain xml) files, which it places in temporary sub-folders for storing the converted ghx files generated by this tool. Any .ghx copies converted with this tool is placed in a subfolder below location of the original gh-file so that the tool can later delete the subfolders if the .ghx copy is no longer needed.

There's a dedicated command for deleting the .ghx file copies by removing the temporary subfolders is created in the first place, including all the folder's content. (GhToGhx does not remove or touch any pre-existing ghx files in anyway which are located in their original folders)

Fig 1. Here an example of Convert ("C") gh files into .ghx versions placed into subfolders named ...\_ghx_tmp

Fig 1.

The tool grabs all gh files in the specified folder (first argument) which doesn't have any ghx equivalent file in the same folder, and makes a .ghx-copy in a sub-folder named ..._ghx_tmp. (Notice that the first version doesn't handle individual files, it only iterates over all files in the specified filepath, disregarding any specified filename).

Fig 2. Pressing the commandline option D (stands for "Dir") to list any temp folders for ghx files created with the Convert command. 5 temp folders was been created, containing .ghx versions of the gh files:

Fig 2.

Fig 3. ... then press "X" for a list of ghx files, of which some already existed before the conversion (and therefore these files were not copied or converted), only a few gh-files (seven) were converted and placed in their respective \_ghx_tmp subfolders (this is so they can easily be deleted later):

Fig 3.

Fig 4.Pressing "G" lists all gh files under the current path, in this case the seven gh-files which were converted above:

Fig 4.

Fig 5. And finally, pressing R for remove, removes the temp folders and files altogether (Ops, I just now noticed that the reporting of the number of deleted files is missing.):

Fig 5.

Grasshopper made searcheable All in all, the few commands in this tool conveniently makes Grasshopper binary files searcheable in a few seconds (Hint: tools like PowerGrep, RegexBuddy and EditpadPro are very useful for regex searching and text manipulation).

HOW TO USE Compile the project in Visual Studio (VS 2017 was used to create the project files) with a reference to the GH_IO.dll, (your own copy of GH_IO.dll is located under the Rhino program install folder) and also place a copy in the same folder as the compiled exe-file (wherever you put it) and it should just work.

  • To run the program, Win10 typically want you to type a period and a slash before the app name, like so:

    .\ghtoghx.exe [...your filepath...] :

  • It is adviced to terminate any folder path with a backslash as to prevent the path from being truncated one step.

  • If you add a second option after the filepath, like G, X, D, C or R (R = Remove), then the app will execute the command and terminate directly after.

Enjoy!