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

#
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.
public const string DoNotAutoMigrate = "DoNotAutoMigrate"

DoNotMigratePersistent

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

DoNotMigratePreview

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

Grasshopper1InstanceId

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

Grasshopper1SourceId

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

Grasshopper1TargetId

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

MigrationGroup

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

MigrationRelay

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

MigrationRelayInput

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

MigrationRelayOutput

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

Properties

BuildDate

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

ComponentType

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

DocObjectType

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

Instance

#
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.
public static Grasshopper1 Instance { get; }

ParameterType

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

Version

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

Methods

CreateAndMigrate

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

CreateAndMigrate

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

CreateDocument

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

CreateDocumentFromXml

#
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.
public IGH_Document CreateDocumentFromXml(
xml
)

CreateObject

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

CreateObject

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

CreateWrapper

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

CreateXml

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

HarvestThumbnail

#
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.
public static Bitmap HarvestThumbnail(
path
)

HarvestWires

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

ParameterPersistentData

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

ParameterVolatileData

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

ReadDataFile

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

ReadDataFile

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

WriteDataFile

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

WriteDataFile

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