I always find my self doing a lot of repetition with fixed TikZ code blocks that I have to rewrite over and over again. My question is that, is it possible to create a block of TikZ executable commands (not just styles) inside a single argument and call that argument as a style?
Consider this:
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{tikzpicture}
\coordinate [label = below:A](A) at (0, 0);
\coordinate [label = above:B](B) at (3, 3);
\draw (A) -- (B);
\draw [|-|, thin] ($(A)! 8mm !90:(B)$) -- node [sloped, midway, fill = white]{$3$cm}
($(B)! -8mm !90:(A)$);%This is too long and It would awesome to abstract it
\end{tikzpicture}
What I would like to know is if there any thing like
\tikzset{
dimension line/.code arg={from#1to#2value#3}
draw the dimension line between (A) and (B),
add a node in the middle with blah style and blau value
}
So that using
\draw[dimension line=from A to B value 3cm] (A)--(B);
will yield the same output. That will help do the job with minimal effort and allow abstraction, I find this example simple enough in order to under stand how to create code blocks in TikZ. Thank you.

