Snapping

Major changes for v0.46.

To help precisely place objects on the canvas, an object can be made to snap to a target. The target can be a Grid line, a Guide Line, or another object's path, node, or bounding box. Snapping takes place when an object's node or its bounding box is near a target. Snapping can be set to always happen or only happen when the object is within a set distance (the Snap Distance) from a target. Snapping can be divide into two parts: setting the target and determining what can be snapped. All snapping options can be set under the various tabs of the Document Properties dialog. Note: Nodes will only snap to other nodes or path, and a bounding box will only snap to another bounding box. Snapping was introduced in the tutorials at the beginning of the book.

Targets

This section covers creating Guide Lines and Grids.

Guides

Guide Lines are individual lines that can be arbitrarily placed. To create a Guide Line, Left Mouse Drag from the left Ruler onto the canvas for a vertical Guide Line or from the top Ruler for a horizontal Guide Line. An angled Guide Line can be created by dragging from the end of a Ruler. By default, the angle is set to 45° if a rectangular Grid is displayed or parallel to the angled lines if an axonometric Grid is displayed. Guide Lines can be moved by dragging them (Left Mouse Drag). They can be removed by dragging them to a Ruler or clicking on them with the Ctrl key held down. Precise placement of a Guide Line and changing its angle can be done through the Guideline dialog, opened by double-clicking on the Guide Line with the Select Tool, Node Tool, or Tweak Tool. A Guide Line is defined by an x-y point through which it passes and an angle. The x coordinate is ignored for horizontal lines and the y coordinate ignored for vertical lines. A Guide Line can also be deleted via the dialog. A check box toggles between absolute and relative placement. Guide Lines can be snapped. This option is toggled on under the Guides tab of the Document Properties dialog. Guide Lines can also be hidden and their color changed in this dialog. To be active, a Guide Line must be visible.

Guide line dialog.
Guide Line dialog showing a line passing through the origin at a 45° angle.

Guide Lines can be created from objects using the Object Object to Guides (Shift+G) command. The keyboard shortcut works with the Select Tool, shape tools, Bezier Tool, and Freehand Tool. Different objects are converted in different ways. In each case, the selected objects are deleted unless the Keep objects after conversion to guides entry is checked in the Tools section of the Inkscape Preferences dialog.

  • Rectangles and Boxes: Guide Lines are drawn along edges, even when rotated, if the Conversion to guides uses edges instead of bounding box box is checked in the Inkscape Preferences dialog. Otherwise the bounding box is used.
  • Paths: A Guide Line is drawn along each straight line segment.
  • Other objects: Guide Lines are drawn along bounding box. The Geometric or Visualbounding box is used depending on which is selected in the Tools section of the Inkscape Preferences dialog.

If a Group is selected, Guide Lines are drawn for each object in the Group.

Guide lines created from objects.
Guide Lines from a rotated Rectangle.
Guide lines created from objects.
Guide Lines from a triangular path, one line for each straight path.
Guide lines created from objects.
Guide Lines from a circle, lines determined from the bounding box.

Grid

Axonometric grids added in v0.46.

A Grid is composed of two or three sets of evenly spaced parallel lines. A RectangularGrid consists of horizontal and vertical lines, much like a sheet of ordinary graph paper. An Axonometric Grid consists of three sets of parallel lines, typically one vertical and two at 30° angles from the horizontal. It is often used to draw three-dimensional objects.

Rectangle and axonometric grids.
Examples of a Rectangular Grid (left) and Axonometric Grid (right).

Grids can be created and edited on the Grids tab of the Document Properties dialog. To create a Grid, select the type (Rectangular or Axonometric) from the drop-down menu at the top of the dialog and then click on the New button. The parameters for the new Grid will then be editable under a tab in the bottom of the dialog. It is possible to have more than one Grid defined (and in use). Each Grid will have a tab entry.

Grids tab.
Grids tab in Document Properties dialog showing the parameters for a RectangularGrid with the default parameters.

Each Grid can individually be Enabled and made Visible by the check boxes on the Grid tabs. If a Grid is not enabled, it will not be visible. However a Grid can be enabled and not visible. All Grids can be enabled or disabled by using the global command View Grid (#). This setting overrides the settings on the individual Grid tabs. Note: There is no visual indication if this overall setting is on or off if the visibility of the individual Grids are all set off. Note also that, depending on the zoom scale, not all Grid lines are shown. “Missing” lines will not be snapped to.

For both types of Grids, the Grid unit can be selected from a drop-down menu and the Grid origin can also be specified. For Rectangular Grids, the x and y spacing can be set independently. For Axonometric Grids the x and z spacings are derived from the y spacing and the angle settings. In both cases the color of the lines can be set by clicking on the color box and making changes in the dialog that pops up.

The default Grid parameters can be modified in the Grids section of the Inkscape Preferences dialog.

Different “views” of the same drawing share the same Grids but the Grids can be enabled or made visible independently for each view.

Snap Parameters

The Snap tab of the Document Properties dialog is used to control what is snapped to what. It is divided into several sections.

In the first section, Snapping, there is a checkbox to control over all snapping. This checkbox supersedes the Enable checkboxes on the Grids tab. The checkbox can be toggled via the View Snap (%) command.

The next section, What snaps controls what points on a moved object or node will snap. The choices are Nodes and Bounding box corners. Both can be enabled or disabled independently. The Nodes mode includes snapping of Handles. It does not include snapping to smooth nodes in a path. The bounding box snapping mode will snap to all four corners of the bounding box. The bounding box used is either the Visual bounding box or the Geometric (nodes only) bounding box, depending on the setting in the Tools section of the Inkscape Preferences dialog. See the introduction to this chapter for more details.

The third section governs what parts of an object to snap to. Choices include: paths, nodes, bounding box edges, and bounding box corners. Snapping will always occur if one or more of these items are selected unless the Snap only when closer than box is checked. If the box is checked, then snapping will only occur if the part to be snapped is closer than the Snap distance to the thing to be snapped to. The Snap distance is in units of screen pixels.

The last two sections govern snapping to Grids and Guide Lines. If snapping to a Grid or Guide Lines is enabled, the snapping will always occur unless the Snap only when closer than box is checked. If the box is checked, then snapping will only occur if the part to be snapped is closer than the Snap distance to a Grid line or a Guide Line (or another snapping rule is satisfied). The Snap distance is in units of screen pixels.

Snap tab.
Snap tab in the Document Properties dialog.

The last tab, Snap points, of the Document Properties dialog has options for special cases of snapping. The first section allows toggling on/off snapping to intersections (Grid lines with Guide Lines or line segments in paths) and the second section covers toggling on/off snapping to the Rotation center of an object.