GenerativeComponents Help

How to Use the DataImporter Node to Populate Other Nodes

Virtually every graphical node type includes the following technique, whose purpose is to populate that node from a DataImporter node.
Note: The same DataImporter node can provide data for more than one node, although this is probably unusual in practice.

ByImportedData - technique

This technique creates a set of child nodes from the data that's contained in a given DataImporter. Typically, each row of data creates one child node.

The following properties define this technique.

CoordinateSystem: CoordinateSystem

The coordinate system in which this node resides. The coordinate values processed from the DataImporter node are assumed to be based on this coordinate system.

DataImporter: DataImporter

The DataImporter node whose data will populate the child nodes of this node.

The simplest situation is when the property, ProcessEachDataRow, is left empty (null). In that case, the data is processed row-by-row, and a child node is created for each row.

The child node's properties are populated from the current data row, by matching up the data column names with the child node's property names.

(This is the primary reason that you may want to use the DataImporter's facilities for giving the columns different names than are defined in the underlying database or file. The column names should match the property names of the node that you're populating.)

ChildTechniqueName: string - optional

Normally, the ByImportedData method determines for itself which technique should be called on each child node. However, a conflict can arise if two or more techniques share the same set of input properties.

In that case, the ChildTechniqueName lets you specify which particular technique should be used. The name is provided as a quoted string.

Note that the ChildTechniqueName is ignored if the following property, ProcessEachDataRow, is non-null.

ProcessEachDataRow: function - optional

A GCScript function that defines precisely how the child nodes should be created from the data.

The preceding section describes the simple case when this function is left empty (null): The child nodes are populated by matching the data column names with the child node's property names.

However, when this function is provided, the child nodes are not created automatically. Rather, it becomes the responsibility of this function to create each child node, and initialize it appropriately.

The given function must be of this general form:

void function(DataRow dataRow)
{
		:
}
For example:
void function(DataRow row)
{
		if (row.Z < 3.8)
			{
					Point pt = new Point(this);
					pt.ByCartesianCoordinates(this.CoordinateSystem,
																														row.X / 2, row.Y, 0);		
			}
}
DataRow is a predefined type of the GCScript language; it represents a single row of data within a data table. In this case, 'row' is the current row that we're processing from the given DataImporter.