Video thumbnail
Row Your Boat (Part 2)
In this video we animate some simple geometry in Grasshopper. We use the component we created in part one to trigger the growth of rectangular prisms.

Back to Animations
Downloads
Code
Below is the C# script we used to make the Row Your Boat component. This is all of the code from our scripting component.
    
// Grasshopper Script Instance
#region Usings
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Drawing;

using Rhino;
using Rhino.Geometry;

using Grasshopper;
using Grasshopper.Kernel;
using Grasshopper.Kernel.Data;
using Grasshopper.Kernel.Types;
#endregion

public class Script_Instance : GH_ScriptInstance
{

    private void RunScript(
	bool reset,
	int counters,
	double speed,
	double waitFor,
	ref object a,
	ref object b)
    {
        if (reset){
            counterList.Clear();
            file_number = 0;
            justReset = true;
        }
        else{
            file_number++;

            if (counterList.Count < counters){
                // Initializing all counters to 0
                while (counterList.Count < counters){
                    counterList.Add(0.0);
                }
            }
            if (justReset){
                justReset = false;
            }
            else{
                for (int i = 0; i < counterList.Count; i++){
                    if (i==0 || counterList[i-1] >= waitFor){
                        if (counterList[i] < 1){
                            counterList[i] += speed;
                            if (counterList[i] > 1){
                                counterList[i] = 1;
                            }
                        }
                    }
                }
            }

        }

        a = counterList;
        b = file_number;
    }

    private List<double> counterList = new List<double>();
    private int file_number = 0;
    private bool justReset = false; // Flag that indicates if the script was just reset
}