Grasshopper1

References
public class Grasshopper1
A set of utility methods for converting Grasshopper 1.0 data and types into Grasshopper 2.0 data and types.

Fields

DoNotAutoMigrate

#
public const string DoNotAutoMigrate = "DoNotAutoMigrate"
If your migrator siphons over all relevant properties from a Grasshopper 1 object and you do not wish for the migration pipeline to set things like UserName, Activity state, Preview state and so on, then add a CustomValue with this key to prevent that automatic logic from running.

DoNotMigratePersistent

#
public const string DoNotMigratePersistent = "DoNotMigratePersistent"
Add a value with this key in the object CustomValues to prevent persistent data from being copied by the automatic migration process.

DoNotMigratePreview

#
public const string DoNotMigratePreview = "DoNotMigratePreview"
Add a value with this key in the object CustomValues to prevent the preview state from being automatically assigned.

Grasshopper1InstanceId

#
public const string Grasshopper1InstanceId = "Grasshopper1InstanceId"
Key for storing Grasshopper 1 instance IDs in the custom values of an object.

Grasshopper1SourceId

#
public const string Grasshopper1SourceId = "Grasshopper1SourceId"
Key for a Grasshopper 1 instance id naming this parameter as the source of that object's outgoing wires.

Grasshopper1TargetId

#
public const string Grasshopper1TargetId = "Grasshopper1TargetId"
Key for a Grasshopper 1 instance id naming this parameter as the target of that object's incoming wires.

MigrationGroup

#
public const string MigrationGroup = "MigrationGroup"
Key marking a group created to hold the objects replacing one Grasshopper 1 object.

MigrationRelay

#
public const string MigrationRelay = "MigrationRelay"
Key marking an object a migrator inserted purely to route data through a conversion.

MigrationRelayInput

#
public const string MigrationRelayInput = "MigrationRelayInput"
Key for the routed input index on a component tagged with MigrationRelay.

MigrationRelayOutput

#
public const string MigrationRelayOutput = "MigrationRelayOutput"
Key for the routed output index on a component tagged with MigrationRelay.

Properties

BuildDate

#
public string BuildDate { get; }
Gets a string describing the build date of Grasshopper 1.

ComponentType

#
public Type ComponentType { get; }
Gets the type which describes the IGH_Component interface as defined in Grasshopper 1.

DocObjectType

#
public Type DocObjectType { get; }
Gets the type which describes the IGH_DocumentObject interface as defined in Grasshopper 1.

Instance

#
public static Grasshopper1 Instance { get; }
Gets the Grasshopper 1.0 interop object, i.e. an instance of GrasshopperPlugin.GrasshopperInterop as exposed via the GetInteropObject() method on the Grasshopper 1.0 plugin object. Invoking this property will cause Grasshopper 1.0 to be loaded if it isn't already. This property will throw if the loading of Grasshopper 1.0 fails.

ParameterType

#
public Type ParameterType { get; }
Gets the type which describes the IGH_Param interface as defined in Grasshopper 1.

Version

#
public string Version { get; }
Gets a string describing the version of Grasshopper 1.

Methods

CreateAndMigrate

#
public IDocumentObject[] CreateAndMigrate(Guid grasshopper1ComponentId, PointF centre)
Create a GH1 object, migrate it to the appropriate GH2 object(s) and position them at the specified location.
grasshopper1ComponentId (Guid)
centre (PointF)

CreateAndMigrate

#
public IDocumentObject[] CreateAndMigrate(string grasshopper1Xml, PointF centre)
Create GH1 object(s) from the document xml, migrate it to the appropriate GH2 object(s) and position them at the specified location.
grasshopper1Xml (string)
centre (PointF)

CreateDocument

#
public IGH_Document CreateDocument(string filePath)
Create a new document wrapper from an existing file.
filePath (string)

CreateDocumentFromXml

#
public IGH_Document CreateDocumentFromXml(string xml)
Create a new document wrapper from a Grasshopper 1 xml archive, such as the text which Grasshopper 1 places on the clipboard during a copy operation. Archives with both "Clipboard" and "Definition" root chunks are supported.
xml (string)

CreateObject

#
public IGH_DocumentObject CreateObject(Guid grasshopper1ComponentId)
Create the default instance of an IGH_DocumentObject, IGH_Component or IGH_Param which matches the given ComponentId.
grasshopper1ComponentId (Guid)

CreateObject

#
public IGH_DocumentObject CreateObject(string grasshopper1ObjectXml)
Create a constructed instance of an IGH_DocumentObject, IGH_Component or IGH_Param which matches the given xml.
grasshopper1ObjectXml (string)

CreateWrapper

#
public IGH_DocumentObject CreateWrapper(object grasshopper1DocObject)
Create an IGH_Param, IGH_Component or IGH_DocumentObject.
grasshopper1DocObject (object)

CreateXml

#
public string CreateXml(IGH_DocumentObject docObject)
Serialize a Grasshopper 1 document object to an xml string.
docObject (IGH_DocumentObject)

HarvestThumbnail

#
public static Bitmap HarvestThumbnail(string path)
Try and load the embedded thumbnail from a GH1 file. This method is static because it does not require Grasshopper 1 to be loaded first.
path (string)

HarvestWires

#
public WireEnds[] HarvestWires(IGH_Document document)
Collect all wires in a Grasshopper 1 document.
document (IGH_Document)

ParameterPersistentData

#
public ITree ParameterPersistentData(IGH_Param parameter)
Extract the persistent data (if any) from a parameter.
parameter (IGH_Param)

ParameterVolatileData

#
public ITree ParameterVolatileData(IGH_Param parameter)
Extract the volatile data (if any) from a parameter.
parameter (IGH_Param)

ReadDataFile

#
public bool ReadDataFile(byte[] file, out string[] names, out ITree[] trees)
Convert the contents of a data file into a collection of named trees.
file (byte[])
names (out string[])
trees (out ITree[])

ReadDataFile

#
public bool ReadDataFile(string file, out string[] names, out ITree[] trees)
Convert the contents of a data file into a collection of named trees.
file (string)File path.
names (out string[])Names of trees in file.
trees (out ITree[])Data trees in file.

WriteDataFile

#
public bool WriteDataFile(Guid origin, string file, string[] names, ITree[] trees)
Create a Grasshopper 1.0 compliant data file from a set of named trees.
origin (Guid)
file (string)
names (string[])
trees (ITree[])

WriteDataFile

#
public byte[] WriteDataFile(Guid origin, string[] names, ITree[] trees)
Create a Grasshopper 1.0 compliant data file from a set of named trees.
origin (Guid)
names (string[])
trees (ITree[])