Program.cs (6.8 KB)
GhFileAnalysis.zip (44.0 KB)
This is a typical function which extracts and displays some information stored in a GH_Archive
instance. The code could probably have more error checking if you want it to deal with corrupt files too, although it is extremely unlikely that a *.gh
file is corrupt and still in any way, shape or form readable. The file is compressed so any damage to it at all will cause a failure in decompression.
private static void DisplayDocumentStatistics(GH_Archive archive)
{
var root = archive.GetRootNode;
var definition = root.FindChunk("Definition");
var header = definition.FindChunk("DocumentHeader");
var properties = definition.FindChunk("DefinitionProperties");
var archiveVersion = root.GetVersion("ArchiveVersion");
var pluginVersion = definition.GetVersion("plugin_version");
var documentId = header.GetGuid("DocumentID");
var documentDate = properties.GetDate("Date");
var documentName = properties.GetString("Name");
Console.Write("Archive Version: "); WriteLine(ConsoleColor.DarkCyan, archiveVersion.ToString());
Console.Write("Plug-In Version: "); WriteLine(ConsoleColor.DarkCyan, pluginVersion.ToString());
Console.Write("Document ID: "); WriteLine(ConsoleColor.DarkCyan, $"{{{documentId}}}");
Console.Write("Document Date: "); WriteLine(ConsoleColor.DarkCyan, documentDate.ToLongDateString() + " " + documentDate.ToLongTimeString());
Console.Write("Document Name: "); WriteLine(ConsoleColor.DarkCyan, $"'{documentName}'");
}