Hello :),
I am developing a grasshopper plugin, and one of my components is a Custom ValueList which should allow the user to select an item, to be used as input for other components.
My code works, in the sense that the component is loaded and I can choose an element from the list, but it seems to give ‘null’ as an output when I connect it to a panel. Is this normal ?
Is my GH_ValueListItem well defined ?
Below is my code.
`
public class ProjectsDropDownList : GH_ValueList
{
public ProjectsDropDownList()
{
Category = "MyCatgory";
SubCategory = "My SubCategroy";
NickName = "projs";
MutableNickName = false;
Name = "proj Picker";
Description = "Provides a proj picker";
ListMode = GH_ValueListMode.DropDown;
}
public override Guid ComponentGuid => new Guid("f151bfa4-d60b-4267-9eb0-184edc0ae091");
protected override void CollectVolatileData_Custom()
{
var selectedItems = ListItems.Where(x => x.Selected).Select(x => x.Expression).ToList();
ListItems.Clear();
var ProjList = MyprojList.Populate();
foreach (var proj in ProjList)
{
var item = new GH_ValueListItem(proj.GetName(), proj.ObjectId.ToString());
item.Selected = selectedItems.Contains(item.Expression);
ListItems.Add(item);
}
if (selectedItems.Count == 0 && ListMode != GH_ValueListMode.CheckList)
{
foreach (var item in ListItems)
item.Selected = item.Expression == ProjList.FirstOrDefault().ObjectId.ToString();
}
base.CollectVolatileData_Custom();
}
}
`
Thanks a lot in advance