GH_Archive
This is the base archive class which takes care of all (de)serialization and messaging.
Inheritance Hierarchy
System.Object
GH_IO.Serialization.GH_Archive
Namespace: GH_IO.Serialization
Assembly: GH_IO (in GH_IO.dll)
Syntax
public class GH_Archive
The GH_Archive type exposes the following members.
Constructors
Name
Description
Public Method
GH_Archive
Initializes a new instance of the GH_Archive class
Properties
Name
Description
Public Property
FileName
Gets the filename (without extension) of the currently loaded data tree. If the path field has not been set, “unnamed” is returned.
Public Property
GetRootNode
Gets the root node of this archive. Typically you do not need to modify the Root. Use functions like CreateTopLevelNode(), AppendObject() and ExtractObject() instead. If you modify the Root node, you may corrupt the archive.
Public Property
Static Member
GH_IO_Version
Gets the version number of the current GH_IO build.
Public Property
Static Member
GrasshopperBinaryExtension
Gets the file extension (including the dot) associated with Grasshopper® Binary data.
Public Property
Static Member
GrasshopperUserExtension
Gets the file extension (including the dot) associated with Grasshopper® User Object file.
Public Property
Static Member
GrasshopperXmlExtension
Gets the file extension (including the dot) associated with Grasshopper® XML data.
Public Property
IsBinaryPath
Gets a value that indicates whether the Path field points to a Binary Grasshopper file.
Public Property
IsPath
Gets a value that indicates whether or not the path field has been set.
Public Property
IsXmlPath
Gets a value that indicates whether the Path field points to an Xml Grasshopper file.
Public Property
Messages
Gets the internal list of messages.
Public Property
Path
Gets the path to the file from which this archive was read and/or written to. If the archive hasn’t been read or written yet, this field will be null.
Public Property
WorstCaseMessageType
Gets the worst case message type. If the record contains at least 1 error, the worst case is GH_Message_Type.error. If the record contains no errors, but at least 1 warning, the worst case is GH_Message_Type.warning. If the record contains no messages or only infos, the worst case type is GH_Message_Type.info.
Methods
Name
Description
Public Method
AddMessage(GH_Message)
Add a new message to the record.
Public Method
AddMessage(String, GH_Message_Type)
Add a new message to the record.
Public Method
Code Example
AppendObject
Appends a target object into the root node of this archive tree. If the root doesn’t exist yet, it will be created. Existing objects at the root scope will not be affected.
Public Method
ClearMessages
Remove all messages from the log.
Public Method
CreateNewRoot
Discards the current data tree and instantiates a new root node. This root node contains some comments, a version value containing the current version of GH_IO.dll and a DateTime value containing the current date and time.
Public Method
CreateTopLevelNode
Creates and returns a new root node for this archive in the form of a GH_IWriter instance. Typically you do not call this method. If you want to add an object to the archive, use AppendObject() instead.
Public Method
Deserialize_Binary
Deserializes an array of bytes.
Public Method
Deserialize_Xml
Deserializes an Xml string.
Public Method
ExtractObject
Extract a target object from the data tree.
Public Method
MessageCount.
Gets the number of messages recorded since the most recent IO operation began.
Public Method
MessageCount(Boolean, Boolean, Boolean)
Gets the number of messages recorded since the most recent IO operation began. Message count can be filtered by message type.
Public Method
Static Member
OpenFileDialog
Displays a standard OpenFileDialog with all the fields set to cater for Grasshopper files.
Public Method
ReadFromFile
Reads a new archive tree from a file.
Public Method
Static Member
SaveFileDialog
Displays a standard SaveFileDialog with all the fields set to cater for Grasshopper files.
Public Method
Serialize_Binary
Serializes the data tree into a Binary byte array.
Public Method
Serialize_Xml
Serializes the data tree into an Xml string.
Public Method
ShowMessageLog
Displays the message log viewer. You should typically only display the viewer if the WorstCaseMessageType equals GH_Message_Type.warning or GH_Message_Type.error
Public Method
WriteToFile
Writes the current tree to a file.