If I use inside the declaration of a tikz-pic the name of a previously defined coordinate, in \pgfpointanchor{}, I get Package pgf Error: No shape named `COORD` is known.
An example of this behavior can be seen below. Where I define two coordinates A and B and then I want to calculate the angle between this two points. But this fails, because in the pic definition latex doesn't know what the coord A or B are.
If I use the same code inside the tikzpicture, it works as expected. What can I do, to enable the defined coords also inside the pic-definition?
\documentclass{standalone}
\RequirePackage{tikz}
\RequirePackage{pgfplots}
\pgfplotsset{compat=1.11}
\usetikzlibrary{positioning,shapes,arrows,shadows,fit,calc,matrix,decorations.text,arrows.meta,shadows.blur,shapes.symbols,automata,fpu,intersections}
\tikzset{
Test/.pic = {
\coordinate (A) at (1, 1);
\coordinate (B) at (0, 0);
\pgfmathanglebetweenpoints{\pgfpointanchor{A}{center}}{\pgfpointanchor{B}{center}}
\draw[red] (B) arc[start angle=0, end angle=360, radius=5mm];
\draw[green] (B) arc[start angle=0, end angle=\pgfmathresult, radius=5mm];
}
}
\begin{document}
\begin{tikzpicture}
%original pic, which is not working
\pictest1 at (0, 12mm) {Test};
%this is the reference, which is working, but should be replaced by the pic
\coordinate (A) at (1, 1);
\coordinate (B) at (0, 0);
\pgfmathanglebetweenpoints{\pgfpointanchor{B}{center}}{\pgfpointanchor{A}{center}}
\draw[red] (B) arc[start angle=0, end angle=360, radius=5mm];
\draw[green] (B) arc[start angle=0, end angle=\pgfmathresult, radius=5mm];
\end{tikzpicture}
\end{document}

name prefix ..is supposed to be used to access external nodes from inside (and not the other way). – Kpym Apr 23 '18 at 19:41name prefix ..only in thedraw) is a better solution. – Kpym Apr 24 '18 at 05:48name prefix ..is not supported in\pgfpointanchor. (or is it?) Because the main problem is, that\pgfpointanchordoesn't see the coordinates. – byteunit Apr 24 '18 at 06:52