Ceci est une ancienne révision du document !
Over the past few instalments, I've detailed the workings of the Tiled Clones dialog. As well as producing some interesting, and often kaleidoscopic, visual effects, this dialog can be useful for creating particular arrangements of objects. Because the dialog's units are based on the bounding box of the parent object (rather than using explicitly stated dimensions), this approach isn't terribly useful for positioning objects at specific coordinates or locations, so the next few articles will look at the different tools Inkscape provides for these kinds of manipulations. It's important to remember, however, that Inkscape is not a “computer aided design” (CAD) program, of the sort used by architects or engineers. If you want to create technical drawings that could be used by builders or manufacturing companies, there are other Open Source programs that might serve you better, such as FreeCAD, OpenSCAD, or QCAD. With each release, Inkscape gains more functionality in this area – such as the new Measure tool in 0.91 – but it's still a long way from a fully fledged CAD application. With that limitation in mind, we'll start with the most obvious form of positioning: snapping to a grid. Inkscape is rather flexible when it comes to grids. You can have more than one active at a time, and each one can be either rectangular (based on horizontal and vertical lines), or axonometric (vertical lines, plus two sets of angled lines). Usually, however, it's easiest to work with just one grid at a time, most commonly a rectangular one. Launch Inkscape to create a new document, and, if there's no grid visible, try pressing “#” or use View > Grid to enable the display of the default grid. To edit this grid, or to add a new one, use the File > Document Properties menu, then select the Grids tab.
To create a new grid, select either Rectangular or Axonometric from the pop-up menu at the top, then click the New button. Each grid gets its own tab in the “Defined grids” section, with slightly different icons for the two grid types – but the icons are always blue, regardless of the color of your grid lines. They're named automatically, with no easy mechanism to change the name, and no distinction in naming between the two grid types. The use of similar, identically-colored icons and fixed, generic names means that managing numerous grids is less than straightforward, so it's best to stick with just one or two. The tab bar isn't scrollable – the dialog just grows in size if you start to add too many; and there's also a practical limit imposed by the UI. Each grid has three checkboxes that control snapping and visibility. These are in addition to the View > Grid option (toggled via the “#” key), so, for a grid to be visible, you need both of the top two checkboxes to be enabled and the View > Grid toggle to be on. Think of the toggle as a global way of showing and hiding all the possible grids at once, with the checkboxes being a way to more finely control what each individual grid contributes. The first checkbox, “Enabled”, simply switches the entire grid on and off. With it unchecked, the remaining options are all disabled and the grid plays no part in snapping or display. You might use this if you have multiple grids so that only one is switched on at a time – typically when swapping between rectangular and axonometric within the same drawing.
The second checkbox, “Visible”, has only a visual effect. With this unchecked, the grid will not be displayed, but can still play a part in snapping if the grid is enabled via the first checkbox. As it can be difficult and frustrating to snap to a grid you can't see, I strongly recommend always leaving this option checked. The third checkbox, “Snap to visible grid lines only”, is slightly misleading with its labelling – though the tooltip is clearer. This checkbox concerns grid lines that are automatically suppressed as you zoom out. If you were to zoom out far enough, the grid lines would become so dense that they just appear as a solid colored background. Inkscape avoids this by hiding grid lines that would be drawn too densely, and would have been a hindrance rather than a help. With this option unchecked, you can still snap to these suppressed lines, but I recommend leaving it enabled so that you snap to only visible grid lines. This may require you to zoom in a little to get the precise snapping point you're looking for, but it's usually a good trade-off against the frustration of constantly mis-snapping to invisible grid lines.
The remaining options in the dialog are used to define the displayed lines, and are fairly self-descriptive. You can position the origin of the grid – 0,0 is good for most drawings – and define the spacing between grid lines in both the x and y directions. As most people usually need a square grid it would be good to have an option to link these values, but it's no great hardship to simply enter the same value into each field. You can set the color, and opacity for the grid lines – it's usually best to keep the opacity low so that they are less dominant on the screen, and less likely to be mistaken for real lines in your drawing. By setting different colors or opacities for major and minor grid lines, you can create a “graph paper” effect. This becomes visible only when you're zoomed in closely enough, and, if you do decide to use this feature, it's best to make the major lines more opaque than the minor ones. Set the “Major grid line every” field to 0 if you want to disable this feature. Finally, the “Show dots instead of lines” checkbox does exactly what it describes, and results in a more lightweight view of the grid. Setting this option, or changing the line colors, can make it easier to work with multiple grids that are all active at the same time, should you need to. The options for creating an axonometric grid are broadly similar to those for creating a rectangular one. There's only a single entry for spacing, and a couple of new fields for defining the angles of the x and z axes. The default values of 30° are fine for isometric drawings, though you might want to use 45° for an “oblique” projection. Setting either of these too close to 0° or 90° results in rendering problems. Any value outside this range is capped, though that isn't reflected in the displayed number. Unfortunately, there's no “Show dots instead of lines” option for axonometric grids.
Also missing is the ability to create logarithmic or polar grids. Both are possible via extensions – though these create “real” SVG objects, rather than Inkscape grids, so they can't be toggled with the “#” key, and have to be snapped to via object snapping, not grid snapping. If you do have need of these grid types, however, you can find them under Extensions > Render. In 0.48, you're looking for the Cartesian Grid and Polar Grid entries, whereas in 0.91 they've both been moved into an extra “Grids” submenu. The image on the next page (top right) gives an example of grids produced using these extensions. Going back to Inkscape's rectangular and axonometric grids, the setup we've done so far just lets you visually align objects. To really use them as layout tools, you'll also need to enable snapping. As with grids, there's a global toggle for snapping: press the “%” key (Shift-5 on my keyboard) to trigger it, use the View > Snap menu entry, or click on the first icon on the Snap Controls Bar (button 1 in the screenshot below). With snapping enabled, you also need to have either button 2 or 3 (or both) enabled. These dictate what parts of your drawing can be snapped: button 2 enables the snapping of bounding box corners, and kicks in when you resize or move an object using the Select tool; button 3 enables the snapping of nodes and handles, so has an effect when you initially draw an object, or subsequently edit it using the appropriate object-specific tool. Enabling either button makes a few others available that you can use to enable more specific snappings – such as snapping the center point of a bounding box, rather than just its corners – but most of the time I find that one of the main two buttons is good enough.
As well as defining which parts of an object should snap, we also have to tell Inkscape what we want them to snap to. Button 4 enables snapping to the grid. The button after it enables snapping to guidelines (covered in Part 16 of this series) – I usually leave this enabled as it has no effect unless you specifically add some guidelines, in which case you probably want it switched on anyway. The other button in this section enables snapping to the page border, which I find to be less useful for my own projects. There's one final setting to look at (shown left) regarding snapping, so it's back to File > Document Properties, but this time select the Snap tab. Within this panel, you can set how voracious Inkscape is in its efforts to snap. For each section, the “Always snap” option means exactly that: snap to the nearest snapping point, regardless of how far away it might be. This is useful if you absolutely have to draw to the grid to ensure dimensional accuracy. More generally, however, “Snap only when closer than” offers a good trade-off between accuracy and freedom. With this mode enabled, you can freely place your objects, nodes and handles, unless they get close to a snapping point, in which case they will jump to that location. Exactly how close is set by the “Snap distance” slider. The values are measured in screen pixels, so zooming has an effect on the effective “hit area” in which snapping occurs: zoom in to give yourself more freedom, or zoom out to make snapping more likely.
Within File > Inkscape Preferences (Edit > Preferences in 0.91), there are “Grids” and “Snapping” panels that offer a few other options. The defaults are usually fine for most users, but if you find yourself heavily using grids or snapping, it might be worth taking a look to see if any of these settings can improve your workflow. With a grid visible and snapping enabled, you should find it quite easy to create shapes that stick to the grid intersections. When you need to place nodes off the grid, you can either press the “%” to disable snapping (whilst leaving the grid visible), or more easily (on a US or UK keyboard, at least) you can press “#” to turn the grid off entirely, removing it as a snap target. Often, however, there's a requirement to place objects relative to one another, rather than to an absolute grid; that will be the subject of the next instalment…