Visualize/Animate G-Code Path

This is a short tutorial on producing animated visualizations for the machine path generated for profiling. You can check virtually the machine tool motion and potentially catch some, but certainly not all, geometric mistakes before running the machine on actual material. The process presented here is very general and it can be used for all sort of animations with Grasshopper.



  1. You have either baked the machine path polyline into Rhino and imported it back into Grasshopper or you have merged this processes with the machine generation process and connected the appropriate wires.
  2. You have opened the template which contains the flute, shank and tool holder solid models (or drawn them with the tool center point at the World origin).


  1. There is a nothing special or difficult about this process. We just use a regular Grasshopper timer to produce a signal.
  2. We connect it to a component that increments an internally persistent variable (which doesn’t reset to the initial value for every tick) also known as a static variable.
  3. We use the numerical tick value as the index to the polyline’s point list.
  4. We apply a Plane to Plane transformation of the tool model geometry from the World basis onto a plane with origin at the polyline’s currently visited point.


  private void RunScript(int Start, ref object Next)
    Next = Index++;

  // <Custom additional code> 

  public static int Index = -1;

  // </Custom additional code> 


  1.  Believe it or not this is the proverbial one-line-of-code application. Well sort-of.
  2. The definition of static variables needs to remain outside the script code block. Any variable defined within the script block expires at the end of the procedure.
  3. Static members retain their state indefinitely. If you want to reset the clock you need to modify the script and let Grasshopper re-compile it.
  4. This is a scaffold or basic logic component. You may include parameters that reset the counter or perform additional logic and control.