I'm trying to calculate the size of a tikzpicture using the current bounding box, but every time I try to extract the coordinates I get 0pt (for everything).

\documentclass{article}
\usepackage{tikz}
\newlength{\mywidth}
\newlength{\myheight}
% computes width and height of tikzpicture
\newcommand{\pgfsize}[2]{ % #1 = width, #2 = height
\pgfextractx{#1}{\pgfpointdiff{\pgfpointanchor{current bounding box}{south west}}
{\pgfpointanchor{current bounding box}{north east}}}
\pgfextracty{#2}{\pgfpointdiff{\pgfpointanchor{current bounding box}{south west}}
{\pgfpointanchor{current bounding box}{north east}}}
}
\begin{document}
\noindent
\begin{tikzpicture}
\draw node[rotate=90]{
\framebox{
\begin{tabular}{c|c}
first column & second column\\
\hline
1 & A\\
2 & B\\
$\vdots$ & $\vdots$
\end{tabular}
}};
\draw[color=red] (current bounding box.south west) -- (current bounding box.north east);
\pgfsize{\mywidth}{\myheight}
\end{tikzpicture}
\noindent
Width = \the\mywidth \\
Height = \the\myheight
\end{document}
As you can see, one can draw a line across the bounding box, so it exists and is non-trivial. I'm thinking I may have to use \pgfgettransformentries, but when?

\mywidthand\myheightlocally, not globally. So outside of thetikzpicture, they'll both be0pt. – A.Ellett Oct 11 '13 at 06:49