I would like to place nodes with given distances relative to each other. For consistence with other drawings these distances have to be very accurate. Node border anchors are placed at the outer borders of the nodes (see pgfmanual 3.0.0, page 702). Therefore, effectively pgflinewidth
(or fractions/multiples of it depending on the nodes shape) is added to the given distance (red nodes in the MWE).
A way to counteract this would be to subtract (fractions/multiples) of pgflinewidth
(blue nodes in the MWE). Another alternative could be to place the nodes w.r.t. their centers. In this case, one would need to know the nodes' widths beforehand which might not be easy for arbitrary node shapes.
My question: Is there an easy way to have node border anchors centered on the borders?
\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[ultra thick, MyNode/.style={draw, minimum height=1cm}]
\draw[step=1cm,gray,ultra thin] (-1cm,-3cm) grid (5cm,2cm);
% default case
\begin{scope}[red]
\path (0,0) node[MyNode, anchor=south west, minimum width=1cm] (n1) {};
\path (n1.east) ++(1cm,0) node[MyNode, anchor=west, minimum width=2cm] {};
\end{scope}
% supstract line width
\begin{scope}[blue, shift={(0,-2)}]
\path (0,0) ++(-0.5\pgflinewidth,-0.5\pgflinewidth) node[MyNode, anchor=south west, minimum width=1cm] (n1) {};
\path (n1.east) ++(1cm,0) ++(-\pgflinewidth,0) node[MyNode, anchor=west, minimum width=2cm] {};
\end{scope}
\end{tikzpicture}
\end{document}