algorithmic modeling for Rhino
I'm attempting to build a small DataTable object to pass around between C# components, however when setting the output parameter to the DataTable object, GH reports that the output is "empty", even when wrapped in GH_ObjectWrapper (although perhaps I'm not getting that correctly?):
// Create list of Column Names:
var dtColsNames = new List<string>();
for (int i = 0; i < columns.Count; i++){
dtColsNames.Add(columns[i].ToString());
}
// Create a DataTable:
DataTable dt = new DataTable();
foreach (string colName in dtColsNames){
dt.Columns.Add(colName, typeof(double));
}
// Create a row in dt:
DataRow row0 = dt.NewRow();
for (int i = 0; i < dtColsNames.Count; i++){
row0[i] = values[i];
}
dt.Rows.Add(row0);
// For fun create a second row:
DataRow row1;
row1 = dt.NewRow();
row1["A"] = 5.6;
row1["B"] = 4.3;
dt.Rows.Add(row1);
// Wrap the DataTable to pass out to another component:
var dtWrapper = new Grasshopper.Kernel.Types.GH_ObjectWrapper(dt);
A = dtWrapper;
I would expect that at least the object would be passed out as a "System.Object"?
I'd prefer to keep this all within native C# components rather than build a library or custom components. Is this possible?
Thanks for any help!
Tags:
When you use a Panel, the data gets converted to a string. Somehow the objectwrapper returns an empty string. However this doesn't tell us all that much, what we really need to know is whether when you plug that data into another C# component, are you able to recover the DataTable?
Welcome to
Grasshopper
© 2024 Created by Scott Davidson. Powered by