Skip to content

Export-Import

In order to work with data more freely and to allow basic exchange of data between different interfaces, several methods are defined to support these tasks.

Bake Bake

It is possible to bake inkObjects when it appears as parameter output in any component. Nevertheless, this specific component allows you to toggle the baking action or to bake by clicking the component button.

An inkObject must contain a geometrical object (e.g. point, curve, brep) in order to bake it to the Rhino document. When an inkObject contains a single key that contains a geometry object, this single geometry object will be baked with user attributes based on the other non-geometric keys in the inkObject. These custom attributes are stored in string format, following the same conversion as used for the Export component.

When an inkObject contains multiple keys that contain a geometrical object (e.g. both a point and a brep in the same inkObject), both geometrical objects will be baked as a group. As Rhino groups do not contain user attributes on their own, each individual geometrical object will be assigned with user attributes as defined by the remaining non-geometric keys in the inkObject. The user attributes which that hold the value inkObject.this.Geometry make sure you are able to properly reassemble the inkObject when making references to baked inkObjects from Rhino to Grasshopper; see below.

Bake component

Reference Bake

Once inkObjects are baked to the Rhino document, they can be referenced in Grasshopper to be reassembled as inkObjects with the help of this component.

Reference component

Serialize Serialize

inkObjects can be serialized to a *.iObj file by the Serialize component. This file contains binary data and is not readable by average humans. When a tree structure of inkObjects is provided, the Grasshopper structure is equally saved. When deserialising a *.iObj file, the Grasshopper structure will be fully restored.

The destination folder for the exported text file needs to exist and is set by right-clicking the component and selecting Choose destination directory... or by clicking the component button. An Explorer window will pop up in which the desired folder can be selected. The name of the exported text file should be set by the filename parameter. The extension *.iObj can be included or omitted when feeding the filename parameter.

Serialize component

Component menu
  • Choose destination directory...
  • Open directory in explorer...

Obviously this component can become laggy when serializing a huge amount of inkObjects.

Deserialize Deserialize

Once a tree of inkObjects was serialized into a *.iObj file, it can easily be deserialized by the Deserialize component.

The file directory of the serialized file needs to exist and is set by right-clicking the component and selecting Select a directory... or by clicking the component button. An Explorer window will pop up in which the desired folder can be selected. The name of the exported text file should be set by the filename parameter. The extension *.iObj can be included or omitted when feeding the filename parameter.

Deserialize component

Component menu
  • Select a directory...
  • Open directory in explorer...

Obviously this component can become laggy when deserializing a huge amount of inkObjects.

Export Export

InkObjects can be exported to csv, xml and json files. The destination folder for the exported text file needs to exist and is set by clicking the main button or right-clicking the component and selecting Choose destination directory... or by clicking on the component button. An Explorer window will pop up in which the desired folder can be selected. The name of the exported text file should be set by the filename parameter. It is important to include the extension (like .csv) in the filename.

By right clicking the Export component, one can set the decimal separator in the component menu. By default the comma (,) is used when exporting to a text file. In case of a CSV file, also a delimiter character can be chosen. By default, a semicolon (;) is used. One can choose the file type by indicating the proper extension in the filename.

Export component

Grasshopper types currently supported as inkObject values for plain export:
  • string
  • integer
  • double/number
  • boolean
  • point3d {0.0, 0.0, 0.0}
  • vector3d {0.0, 0.0, 0.0}

Other types like curves, breps, solids, complex numbers, etc. will be casted to a string by the method ToString().

Component menu
  • Choose destination directory...
  • Set decimal separator
  • Set delimiter character (csv)
  • Show file in explorer...
  • Open file...

CSV export does not allow for multi-line data.

Import Import

It is possible to assemble inkObjects from the following text formats: csv, xml and json. By right-clicking the component and selecting the menu item Select file directory..., you can choose through a pop up explorer window the directory of the file that needs to be imported and casted to inkObjects. Similarly as the Export component, one can open the file or file location by the component menu.

Import component

The structure of the text file is quite strict and may not contain any nested data. The Import component assembles inkObjects by assigning values to a key, as specified in the textual serialization.

Casting from plain text

As the values are read as a string and no nested data is allowed (yet?), the following data types are automatically recognized:

  • string
  • integer
  • double
  • boolean
  • point3d
Component menu
  • Select file directory...
  • Set decimal separator
  • Set delimiter character (csv)
  • Show file in explorer...
  • Open file...
Examples fragments for csv import
"my_point";"my_number";"my_integer";"my_string"
"{77.10939, 39.90027, 69.636895}";0,696368945621126;0;"String value!"
"{40.416259, 61.988389, 18.47724}";0,184772395614894;1;"String value!"
"{16.599867, 73.76624, 36.321888}";0,363218880427638;2;"String value!"
Examples fragments for xml import
<root>
    <inkObject>
        <my_point>{77.10939, 39.90027, 69.636895}</my_point>
        <my_number>0,696368945621126</my_number>
        <my_integer>0</my_integer>
        <my_string>String value!</my_string>
    </inkObject>
    <inkObject>
        <my_point>{40.416259, 61.988389, 18.47724}</my_point>
        <my_number>0,184772395614894</my_number>
        <my_integer>1</my_integer>
        <my_string>String value!</my_string>
    </inkObject>
    <inkObject>
        <my_point>{16.599867, 73.76624, 36.321888}</my_point>
        <my_number>0,363218880427638</my_number>
        <my_integer>2</my_integer>
        <my_string>String value!</my_string>
    </inkObject>
</root>
Examples fragments for json import
[
  {
    "my_point": "{77.10939, 39.90027, 69.636895}",
    "my_number": "0,696368945621126",
    "my_integer": "0",
    "my_string": "String value!"
  },
  {
    "my_point": "{40.416259, 61.988389, 18.47724}",
    "my_number": "0,184772395614894",
    "my_integer": "1",
    "my_string": "String value!"
  },
  {
    "my_point": "{16.599867, 73.76624, 36.321888}",
    "my_number": "0,363218880427638",
    "my_integer": "2",
    "my_string": "String value!"
  }
]