protected override void SolveInstance(IGH_DataAccess DA) { ghGrid = new GH_Grid(); if (!DA.GetData(0, ref ghGrid)) { return; } if (GridHasChanged()) { hasValidControls = false; point = new IvyCore.Parametric.Point(ghGrid.Value); // cache a DeepCopy ghGridCache = ghGrid.DeepCopy(); this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Grid Has Changed. Reset Controls via Menu."); this.Message = "Select Controls in Menu"; } // If controls are valid, then compute the point if (hasValidControls) { UpdatePoint(DA); DA.SetDataList(1, point.Coord); DA.SetData(2, point.CellIndex()); } else { this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Grid Has Changed. Reset Controls via Menu."); this.Message = "Select Controls in Menu"; } DA.SetData(0, ghGrid.Value.Info()); }
private bool GridHasChanged() { if (ghGridCache == null) { // cache a DeepCopy ghGridCache = ghGrid.DeepCopy(); return(true); } var b1 = Grid.IsEqualData(ghGrid.Value, ghGridCache.Value); var b2 = Grid.IsEqualLabels(ghGrid.Value, ghGridCache.Value); return(!(b1 && b2)); }