Hello, is there an event for button and toggle values?
I use SolutionStart
. How can we improve the code?
private void RunScript(object x, object y, ref object A)
{
GH_Document ghDocument = Grasshopper.Instances.ActiveCanvas.Document;
ghDocument.SolutionStart -= DocChanged;
ghDocument.SolutionStart += DocChanged;
Buttons();
A = buttonsValues;
}
// <Custom additional code>
List<GH_Boolean> buttonsValues = new List<GH_Boolean>();
private void DocChanged(object sender, GH_SolutionEventArgs e)
{
Component.ExpireSolution(false);
}
void Buttons()
{
GH_Document ghDocument = Grasshopper.Instances.ActiveCanvas.Document;
buttonsValues.Clear();
foreach (var obj in ghDocument.Objects)
{
if(obj.GetType() == typeof(Grasshopper.Kernel.Special.GH_ButtonObject))
{
Grasshopper.Kernel.Special.GH_ButtonObject button = (Grasshopper.Kernel.Special.GH_ButtonObject) obj;
buttonsValues.Add(new GH_Boolean(button.ButtonDown));
}
}
}
btn_event.gh (7.8 KB)