About shape grammars
The interpreter project
Create a grammar
Run a grammar
Get out of trouble
The Yingzao fashi project
A fractal specified by a grammar of two rules.
Now that you’re set up, let’s draw a grammar in Rhino.
Set up a new grammar
- Create a new Rhino document (File / New). I usually use the template Small objects / millimetres, although it may not make any difference.
- Open the Python script editor. Open the Python script editor (Tools / PythonScript / Edit).
- Open the ‘new_grammar’ script. Select File / Open. Navigate to ‘package / commands / new_grammar’. The script opens in the editor. (Try not to change the script. If you do, close the script without saving.)
- Run the ‘new_grammar’ script. Click the green play triangle or select File / Run Script. This clears the Rhino document and creates two layers: one for the first initial shape and one for the first rule. Each layer has one or two cubic frames.
Draw the initial shapes and rules
- Draw the initial shape and the first rule. Use lines and textdots (for labeled points) to create the shapes. Draw each shape on the correct layer and completely inside the frame. See the tips below on drawing shapes.
- Add new initial shape and rule layers as necessary using the ‘new_initial_shape’ and ‘new_rule’ scripts.
Tips on drawing shapes
- You can use polygons, polylines, and blocks. If you do, explode them into lines. But don’t explode the frames.
- You can use scripts to draw shapes.
- You’re drawing in three dimensions, so you can create three-dimensional shapes (the interpreter can handle them).
- To work with a curve, you can try replacing it with lines connecting its control points. (I haven’t tried it, so if you do, let me know how it goes.)
Export the grammar
- Go through the pre-export checklist below.
- Export the grammar as a .dat file. Use the ‘export_grammar’ script.
- Save the grammar regularly (as a Rhino .3dm file).
Pre-export check list
- Check that your shapes consist of only lines and textdots.
- Check that the frames are block instances. If you exploded a frame, delete its lines and insert a new frame block on the appropriate layer.
- Use the top, front, and right views to check for any elements that lie outside a frame, even partially.
- Use the perspective view to check that lines are what you think they are. For instance, a line that in the top view appears parallel to the xy-plane may not be.
- Set the current layer to ‘Default’. Turn the initial shape and rule layers off one at a time to check that lines and textdots are in the correct layer.
- Check that your lines are maximal, i.e., that you have no duplicated, overlapping, or abutting collinear lines.
- Check that the left and right shapes of each rule are correctly located in their frames. The front lower left vertex of each frame is the origin for the shape it contains.
i (at) andrew (dot) li