Hi guys,
A. I m trying to figure out why getting the data from a GalapagosGeneListObject is not successful with the first attempt of the following code. Luckily the second attempt worked, but I am curious to know more about their differences.
protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager) {
pManager.AddGenericParameter("Gene pool parameters", "genePool", "The genePool to get the parameters from", GH_ParamAccess.item);
}
protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager) {
pManager.AddGenericParameter("Array of parameters", "params", "The list of genes as a list of parameters", GH_ParamAccess.item);
}
protected override void SolveInstance(IGH_DataAccess DA) {
double[] parameters = new double[] { };
// ATTEMPT #1: FAILED
/*
if (DA.TryGetItem(0, out GalapagosGeneListObject provided_params)) {
parameters = new double[] { (double)provided_params[0], (double)provided_params[1], (double)provided_params[2] };
}
*/
// ATTEMPT #2: WORKED
foreach (IGH_Param param in Params.Input[0].Sources) {
GalapagosGeneListObject provided_params = param as GalapagosGeneListObject;
parameters = new double[] { (double)provided_params[0], (double)provided_params[1], (double)provided_params[2] };
}
DA.SetData(0, parameters);
}
B. As shown at the figure, for a GalapagosGeneListObject with 3 genes I created 3 arrays. I simply wanted one array which contains the genes. Any ideas what I am doing wrong?
Thanks