Sunday, October 23, 2016

2D Patterns in Grasshopper

This post covers building Grasshopper definitions for generating parametric 2D patterns. This includes using the built in grids Rectangular, Triangular, Radial, and Hexagonal. It also covers Voronoi patterns. Grid manipulation using attractor points, and attractor curves is covered. Finally, use of the Graph Mapper and Image Sampler is covered.

Rectangular, Triangle, Hexagonal and Radial Grids

This section describes a number of components for creating grid.

Rectangular Grid

A very common arrangement is the rectangular grid. This is created with the Rectangular component in Grasshopper. You specificy a plane for the grid, sizes in X and Y for each cell, and extents in X and Y (the number of cells in each direction).

The cells are output as a data tree. For more information on Data Trees and their usage please see Data Matching and Data Trees in Grasshopper.

You can find the center of each cell using the Area component. It computes the area of each cell and also outputs the center point. This component is very useful in many pattern making definitions.

Triangular Grid

You can generate 2D grids with triangular cells using the Triangular component. The parameters are the same as the rectangular grid. 

Hexagonal Grid

You can use the Hexagonal component to make 2D grids composed of hexagons. Same parameters as above.

Radial Grid

The grid cells of radial grids build outward from a center point and radiate in a circle. 

Voronoi Diagram

A Voronoi diagram starts with a group of points in a plane. These points are called the seeds. The cells in the diagram are drawn such that all the points contained within a cell are closer to the seed point in the cell than to any other seed points.

You can use the Rhino Points command to place points on a plane then use the Grasshopper Voronoi component build the cells. Here's a simple example:

The Voronoi diagram is a dual of its Delaunay triangulation. This can be created with the Delaunay Mesh component. Make sure Display > Preview Mesh Edges is selected in the Grasshopper drop-down menus. The Delaunay triangle mesh is shown below in green.

You can automatically generate random points using the Pop2D component. There are sockets for the number of points and also a seed value. Different seeds result in different randomized point arrangements.

There is a socket for a Boundary which will form an outer edge to the cells. A convieient component for this is the Bounding Box component. Make sure that the Union Box option is checked:

Smooth Voronoi

The Voronoi cells are degree 1 curves (polylines). You can use the control points to build new curves which are smooth. This gives a different effect to the diagram.

The definition follows. It simply divides the Voronoi cell polylines into the specified number of points. Then these are used as input to create a new, smooth NURBS curve. You can add an additional Offset curve component to get some more space between them if you like.

Attractor Point

A popular pattern in architectural modeling and fabrication is the use of attractor points and curves. These distort or influence a pattern by exerting a force (often a scale) on the geometry based on the proximity of the parts of the pattern to a point or curve.
The Hexagonal component generates a hexagon grid. The Points output socket returns the centroid (center point) of each hexagon. This is used in the distance measurements and as the center of scaling of the hexagons.

The Distance component is the key to this definition. It measures the distance from the attractor point to the center of each cell. It outputs this distance as a list, one value for each hexagon in the grid. Normally, you want the geometry to scale smaller near the attractor point.

You also need to adjust the influence of the effect. This is done with the Division component. It divides the distance by a factor, shrinking its effect or area of influence.

Finally, you usually want to limit the effect to shrinking the hexagons rather than enlarging them (which visually breaks the grid). So a Minimum component is used to return the smaller value – the scale factor or 1. So anything larger than 1 will be set to 1 exactly. This keeps the distant hexagons beyond the range of influence at their original size.

Attractor Curve

Rather than a point, a curve can be used. It is the proximity of each cell to a curve which determines the scaling.

The essential component in this definition is Curve Closest Point. This takes a list of points as input (these are the center of each hexagon) and a curve. It returns a list of the distance of a hexagon center to the closest point on the curve for that center point.

In the provided sample Grasshopper file the curve is saved in the GH file. Therefore you can't edit it. However you can draw your own curve and then right-click on the Curve component and "Set One Curve" to use your own. Then you can alter it as you wish.

Graph Mapper

The Graph Mapper component is very useful for transforming a list of input values using a graph function. The following examples make this clear.

This definition uses a Series component to generate a list of values in the range 0 to 0.9. This list of values is fed into the Graph Mapper. It takes each value (which can be thought of as the X axis on the graph) and returns a list of values where they hit the Y axis on the graph. In this example below the graph is a straight line at 45 degrees. So the output value matches the input value. To make this graphically clear the X value is fed into a Construct Point component. The output of the Graph Mapper is fed into the Y value.

You can see the resulting points in the viewport - a straight line which matches the graph:

If you hook up a Nurbs Curve component it will draw a curve through the points as shown below.

Also the graph type has been changed. This is done by right-clicking the Graph Mapper and choosing a new type from the Graph Type fly-out:

Graphs usually have grips (small circles) which can be used to modify the variables that control the graph. Below a sine wave graph type was used. The grips have been pulled a bit to reshape the graph. The resulting curve drawn in the Rhino viewport shows the matching result.

The power of the Graph Mapper comes from its ability to map any range of values. You can double click the component to edit the expected input range as well as the desired output range:

Alternatively you can remap the input range to 0 to 1 and not have to change the range. You can do this using the Bounds and ReMap Numbers components as shown below:

You can compare the values in the two Panels. Note how the input range (0 to 18.36) has been remapped to the Target range (which defaults to 0.0 to 1.0). The Mapped value could then be fed into the Graph Mapper.

Colorize Cell Based Patterns

By adding three components it's possible to colorize the pattern. These components are Boundary Surfaces, Gradient, and Custom Preview. The idea is to create a planar surface from the closed curves (cells), generate a color for each one, then preview it in the viewport. Here's an example which also uses a Graph Mapper:

Boundary Surfaces is given the scaled geometry. It outputs a surface which is needed so color can be assigned. The Gradient component is fed the distance values as modified by the Graph Mapper and generates a color accordingly. Much like the Graph Mapper the Gradient expects values with a specified range. In its case between it's Lower Limit and Upper Limit. The color is then generated and fed into the Custom Preview which shows it in the viewport.

You can use the right-click menu on the Gradient to change to different built in color gradients.

Image Sampling to Modify Cells

The Image Sampler component lets you use an image file (bitmap) to generate data. In our case, this data can be used to modify a grid. Here's an example image and modified rectangular grid:

The grayscale value in the image is used as a scale factor for the cells in the image. White pixels generate a scale factor of 1.0. Black pixels scale to 0.0.

A grid of points is needed to sample the image. By default these need to be in the range 0.0 to 1.0 in both X and Y. Various aspects of the image can be sampled, for example individual Red, Green or Blue values or the grayscale value.

You can simply drag and drop an image file onto the Grasshopper canvas to create an Image Sampler with that image assigned. Double click the component to bring up its settings dialog: 

Here you can set the expected range of values in X and Y. You can control how values outside that range behave (clamped, tiled, etc). You also set the channel used to sample in this dialog. If you check the "Save in file" option the image is saved in the GH file.

Thursday, September 15, 2016


This post is a basic overview of plastics, some common types, and their properties. There's a particular emphasis on some of the plastics used in digital fabrication processes (3D printing and vacuum forming).


The word plastic is derived from a Greek word (plastikos) meaning "capable of being shaped or molded". Plasticity is the general property of all materials that are able to irreversibly deform without breaking. This occurs to such a degree with plastics that their name is an emphasis on this ability.


There are two basic types of plastics:

  • Themoplastic
  • Thermoset

The primary difference between these two is that thermoplastics can be remelted back into a liquid and then reshaped and reused. Thermoset plastics always remain in a permanent solid state. 

Thermoplastics Plastics

Thermoplastics pellets soften when heated and become more fluid as additional heat is applied. The curing process is completely reversible as no chemical bonding takes place. This characteristic allows thermoplastics to be remolded and recycled without adversely affecting the material’s physical properties.

Most materials commonly offer high strength, shrink-resistance and easy bendability. Depending on the resin, thermoplastics can serve low-stress applications such as plastic bags or high-stress mechanical parts.

Thermoplastics Pros

  • Highly recyclable
  • Aesthetically-superior finishes
  • High-impact resistance
  • Remolding/reshaping capabilities
  • Chemical resistant
  • More environmentally friendly manufacturing

Thermoplastics Cons

  • Generally more expensive than thermoset plastics
  • May melt if heated

Thermoset Plastics

Thermoset plastics contain polymers that cross-link together during the curing process to form an irreversible chemical bond. The cross-linking process eliminates the risk of the product remelting when heat is applied, making thermoset plastics ideal for high-heat applications such as electronics and appliances.

Thermoset plastics significantly improve the material’s mechanical properties, providing enhances chemical resistance, heat resistance and structural integrity. Thermoset plastics are often used for sealed products due to their resistance to deformation.

Thermoset Pros

  • More resistant to high temperatures than thermoplastics
  • Can be used for both thick to thin wall products
  • Higher levels of dimensional stability
  • Cost-effective

Thermoset Cons

  • Cannot be recycled
  • More difficult to surface finish
  • Cannot be remolded or reshaped

Common Plastic Types and Uses

A brief list of some commonly used plastics: 

Polyurethanes (PU) – Used in cushioning foams, thermal insulation foams, surface coatings.
Polycarbonate (PC) – Used in compact discs, eyeglasses, riot shields, security windows, traffic lights, lenses.
Polylactic acid (PLA) – A biodegradable, thermoplastic derived from lactic acid commonly used in 3D printing.
Acrylonitrile butadiene styrene (ABS) – Used in 3D printing, electronic equipment cases (computer monitors, printers, keyboards).
Polycarbonate/Acrylonitrile Butadiene Styrene (PC/ABS) – This is a blend of PC and ABS that creates a stronger plastic. Used in car interior and exterior parts, and mobile phone bodies.
Polyester (PES) – Used in fibers, textiles.
Polyethylene terephthalate (PET) – Used in carbonated drinks bottles, peanut butter jars, plastic film, microwavable packaging.
Polyethylene terephthlate Glycol-Modified (PETG) – Used in vacuum formed products.
Polyethylene (PE) – Used in a wide range of inexpensive uses including supermarket bags, plastic bottles.
High-density polyethylene (HDPE) – Used in detergent bottles, milk jugs, and molded plastic cases.
Low-density polyethylene (LDPE) – Used in outdoor furniture, siding, floor tiles, shower curtains, clamshell packaging.
Polyvinyl chloride (PVC) – Used in plumbing pipes, window frames, flooring.
Polypropylene (PP) – Used in bottle caps, drinking straws, yogurt containers, appliances, car fenders (bumpers), plastic pressure pipe systems.
Polystyrene (PS) – Used in packaging foam ("peanuts"), food containers, plastic tableware, disposable cups, plates, cutlery, CD cases.
High impact polystyrene (HIPS) - Used in refrigerator liners, food packaging, vending cups.
Polyamides (PA) (Nylons) – Used in fibers, toothbrush bristles, fishing line.

3D Printing Plastics

A comparison of the properties of some common 3D printing plastics: PLA versus ABS.

PLA - The wide range of available colors as well as translucent material is often desirable. PLA can also have a glossy feel to it. The plant based origins are appealing as is the semi-sweet smell as compared to ABS. When properly cooled, PLA generally has a higher maximum printing speeds, lower layer heights, and sharper printed corners. Combining this with low warping on parts make it a popular plastic for home printers, hobbyists, and schools.

ABS - Its strength, flexibility, machinability, and higher temperature resistance make it often a preferred plastic for engineers, and professional applications. ABS has a petroleum base which is less applealing to some. The hot plastic smell deters some from its use. The requirement of a heated print bed means there are some printers simply incapable of printing ABS with any reliability.


The greatly expanding use of plastics in the early 20th century resulted in environmental concerns due to its slow decomposition rate after being discarded. Thermoplastics can be remelted and reused. Thermoset plastics can only be ground up and used as filler material (although the purity degrades with each reuse).

  1. PET (PETE), polyethylene terephthalate
  2. HDPE, high-density polyethylene
  3. PVC, polyvinyl chloride
  4. LDPE, low-density polyethylene,
  5. PP, polypropylene
  6. PS, polystyrene
  7. Other types

Wednesday, August 31, 2016

CNC Router Rotary Axis

This post documents adding a rotary axis to my CNC Router Parts router.

My router was a 3-axis machine. Adding a 4th rotary axis allows considerably more flexibility as the part to be machined can be rotated to expose different faces for cutting. I'd previously done some 4-axis router work at Stamps School of Art & Design - here's that post. I really wanted to add this capability to my router.

After exploring a few options - most of which were very expensive - I chose to go with an inexpensive kit from China. It was only $358 including shipping. I'd have to figure out how to get it hooked in to the electronics then build my own mount.

Rotary Axis Hardware

I ordered it and it shipped from Hong Kong the next day. It was ordered on Thursday June 30th and arrived in Michigan, USA on Tuesday July 5th. Not bad!

It includes a tail stock, a self-centering 4 jaw chuck, a Nema 34 stepper motor, and a 4:1 ratio belt drive. It includes both inside and outside jaws.

Electronics Hookup

To connect it to my setup I had to solder on a 4 pin XLR male connector.

Then using one of CNC Router Parts standard cables I could plug directly into my controller:

I had to set the dip switches in the electronics cabinet to match the 4.8 amps of the motor (the other motors I'm using are 7 amps). Then set the steps per revolution in Mach3 and it was ready to run.

Under Table Mount

I went through several iterations when designing how to mount the motor/chuck and tailstock. The requirements were:
  • It had to be always hooked up - never removed from the machine. I wanted to be able to use it without much hassle. 
  • It had to be moved out of the way when I wanted to 3-axis route using the entire 4'x4' bed. 
  • It had to be rigid when locked in place. 
  • And it obviously had to support a variety of part sizes including wide ones. 
I messed around with a lot of ideas. One was cantilevering the parts from one of the horizontal rails in the frame. But I thought this would be too much torque on the frame - the motor/chuck weighs 19 pounds.

In the end I decided to make it out of aluminum extrusions. I  choose components from 80 / 20 Inc. They have quite a few parts including sliding ones. And a great CAD library of their parts. So I could fully 3D model the design.

This is the final design, as seen from below the table. The existing frame is light blue. The new components are gray. The handles shown lock movable parts of the assembly.

Here's a front view of the frame in the lowered, beneath the table position, so 3-axis routing can happen over the full table:

Here's the frame raised up, slid up those verticals, ready to route. The center line of the axis is right at the top of the table. That's the lowest reach of the spindle:

Here's the tail stock moved forward for a smaller part. It slides along on the horizontal rail:

This configuration allows for a part that's 22" long and 14" in diameter.

After having 80/20 review the design they gave me a quote. The parts arrived at my house in just under two weeks.


The parts were easy and enjoyable to put together. The linear bearings as 80/20 refers to them work quite well. Things slide smoothly and lock solidly,

Loosen the four corner yellow handles and you can lower the entire assembly beneath the table.

In the up position the centerline of the axis is right at the top of the frame which is close to the lower limit of the reach of the tool.

Chuck Setup

The 4th axis has a four jaw self-centering chuck which has to be assembled in a particular sequence. If this isn't followed the jaws will not all line up correctly. This process is outlined below:

Identify the numbered jaws and the numbered slots. The jaws are labelled on their side. The slot numbers are stamped into the back face of the slot (you'll need a flashlight to see them).

  • Using the key, turn the scroll observing the number one slot until the outermost end of the scroll appears. You should see the edge of the thread just appearing to enter the slot. 
  • Next turn it back a little just enough to allow the #1 jaw to enter the slot. 
  • Then push the jaw down as far as it will go (which isn't very far). 
  • Next, using the key turn the scroll so that it engages the first tooth of the jaw and starts to pull it inwards. You can give it a light tug to make sure it's engaged. 
  • Rotate the chuck until the next slot is up then turn the scroll until the start of the thread appears in the next slot. 

Repeat the above with the #2 jaw and continue with jaws 3 and 4. This procedure ensures that all the jaws are synchronized with the scroll. Here you can see them coming together properly, and aligned with the point of the tail stock:

Alignment / Calibration

The rotary axis needs to be exactly aligned with the Y axis of the router. X needs to be zeroed over that axis. And the Z height needs to be zeroed on the centerline.

I bought an aluminum cylinder to use as a calibration tool. It was very straight and uniform in diameter (1.875").

As carefully as I could I marked the centerline, and used a punch to create a starter dent in the end.

Then I drilled a small hole which will accept the tail stock point.

This bar then gets chucked up between the centers. I put a dowel pin in the spindle and carefully jogged the axis to look for variations using a feeler gage. One end of the horizontal rail can be moved to level things out.

I had to tweak the tailstock location a teeeeeny bit in X to get it aligned. But this is really about as good as I can get it without a probing routine which touches off at multiple points on the bar and compensates for any axial deviation in software. If I can locate a Mach3 probing routine I'd certainly like to try it.

Toolpath Programming

There are several possibilities for how to program the cutting. A powerful, but very simple method is to simply rotate the part to a new face, then 3-axis mill it from that position.

I'm using my standard 3-axis router profile. I manually rotate the chuck using the MDI interface of Mach3. I just type in G90 G0 A90.0 and it rotates to an absolute rotation of 90 degrees. Then I run the toolpath from the side. Doing G90 G0 A-90.0 and it rotates to the other side. It's really easy, and of course keeps the simple 3-axis toolpath programming.

An alternative is to rotate the part as it is cutting much like a slow speed lathe.


I'm excited to finally have this running. First work will be some portrait sculptures much larger than I've been able to do in the past.