# ASCII knots to 3D renderings via Blender ![-](imgs/header.png width="60%") Knots are a pain to model in 3D. I mean "knots" as in the functional objects used to bind materials, like those [Ashley wrote about](https://en.wikipedia.org/wiki/The_Ashley_Book_of_Knots), rather than mathematical knots, for which there are [some nice tools available](https://knotplot.com/) to produce renderings. Such knots are also a pain to notate consistently in a form that can be shared over email or chat -- people often end up discussing knots in terms of their Ashley numbers (**ABOK #1010** is the Bowline, for example), which is fine if you (a) have a copy of the Ashley Book of Knots handy and (b) the knot is actually listed there. Many of the interesting knots noted at the [Notable Knot Index](https://notableknotindex.webs.com/), for example don't fall into that category. While the Notable Knot Index has nice illustrations, these are tricky to produce by hand and of course show only a single perspective on the construction. I've devised a simple notation (knotation) for representing basic knots, and a plugin for Blender that will parse this notation and generate 3D models automatically. It only generates a *starting point* for modelling, with the correct topology and approximate geometry, but it is a useful helper. ## Some example renderings ![Examples of knots rendered from ASCII diagrams]("imgs/examples.png") ## Blender plugin I have created a Blender plugin (2.7x/2.8x) to create 3D meshes of knots from these ASCII art descriptions. This is a simple plugin, which allows the creation of a knot mesh quickly. It generates Blender spline curves from the text, which can be extruded to build full 3D meshes. Generating a "good looking" knot with appropriate tension and curvature takes a bit of manual editing, but it is usually quick to do. ### Installing the plugin [Download the package](https://github.com/johnhw/blender_knots/archive/0.2.zip) See the [readme](https://github.com/johnhw/blender_knots) for full details on installing and using the plugin. ## Knotation: The notation is a simple ASCII art representation of the path of the rope. The rope can go in each of the four cardinal directions (up, down, left, right), and can go beneath existing rope. ### Examples It's easier to first see some examples in the notation: #### Reef knot ``` +--+ >--------|-----+ | +----------< | | | +----------> <--------|-----+ +--+ ``` ![]("imgs/reef.png" width="50%") #### Figure of 8 ``` +--+ | | >-----|-----+ | | | +--|-----> | | +--+ ``` ![]("imgs/fig8.png" width="50%") #### Bowline ``` V | | /|-\ \-\| /--||-\ | \---/ | || | V| \---/ ``` ![]("imgs/bowline.png" width="50%") ### Leads Every knot is represented as a collection of **leads**, where one a **lead** is a separate piece of rope. A simple overhand knot only has one lead; a bend will have at least two leads, and so on. * **lead** a connected sequence representing one physical strand of rope * Every lead must have a **head**; either directed, undirected or numbered * A lead may have an explicit **tail** (ending marker), either directed or undirected but this is optional * **space** any cell without any character #### Lead characters * `- |` connected elements of a **lead**, horizontal or vertical ``` --------- | | | ``` ##### Under/over A **lead** is assumed to continue underneath if it disappears without a corner symbol: ``` V V | | >---|--- >------ | | ``` This may continue for any number of steps: ``` VVV ||| >----|||---- ||| ||| ``` #### Corners * `+` undirected corner Indicates a change of direction in a **lead**. Must be unambiguous when following the path of the **lead** **OK**, unambiguous ``` >----+ | +---- | >--------++-< | ``` **NOT OK:** ambiguous ``` | >-----+ | ``` * `/ \` directed corner; Can be used to explicitly annotate direction of corner ``` | | >--------/ >----\ | ``` ### Heads/tails * `^ v > <` Directed **head** Indicates **head** of a **lead**, if facing a **lead** (i.e. *before* a `-` or `|`), or the **tail** if facing whitespace ``` >--- [head] ---> [tail] V [head and tail] | | V ``` * `[0-9]` undirected **head** Indicates start of a **lead**. Labels a lead with the given number. Only one digit permitted. Must neighbour exactly one **lead** cell so that direction is indicated. ``` 0--- 0 | | ``` * `.` Undirected tail (optional) ``` ---. | | . ``` #### Comments/names * `[name]` names a **lead** May appear anywhere on the **lead** excluding the end, including before the **head** or in place of the **head**. Always read left to right, regardless of line orientation. The **lead** must pass through the name to take effect. Can be used as a comment if not adjacent to a **lead**. *The Blender script does not use the names for anything at the moment.* ``` [a comment; this --- is ignored] V | [this has a lead through it and will name the lead] | . ``` ``` >[left]---> <---[right]< 0 | | [left] | | V ``` --- [John H Williamson](https://johnhw.github.io) [GitHub](https://github.com/johnhw) / [@jhnhw](https://twitter.com/jhnhw)