[Tex/LaTex] Accessing colors defined by a beamer color theme for a standalone tikzpicture

beamercolorstandalone

This is a follow-up to this question.

I use the standalone documentclass to externalize my tikzpictures. Now, I want to include it in a beamer presentation with its color theme set to, say, default. I'd like that the colors I use in the standalone tikzpicture match those defined in the presentation (structure, normal text.fg, example text.fg, etc). How can I do?

Ideally, I'd like something like

\documentclass{standalone}
\usepackage{tikz}
\ImportColorDefinitionsFromBeamerColorTheme{default}
\begin{document}
\begin{tikzpicture}
  \draw[structure.fg] (0,0) -- (1,1);
  \draw[palette primary.fg] (0,1) -- (1,0);
\end{tikzpicture}
\end{document}

(notice that palette primary.fg won't work in beamer either, one need to use \usebeamercolor[fg]{palette primary} and I don't know how to do it with tikz).

Best Answer

\documentclass[tikz,beamer]{standalone}
\begin{document}
\begin{tikzpicture}
  \draw[structure.fg] (0,0) -- (1,1);
  \usebeamercolor{palette primary}
  \draw[fg] (0,1) -- (1,0);
\end{tikzpicture}
\end{document}