# Failed to use the local bounding box produced by \foreach and \pic

I was confronted with a problem of \pic and \foreach in Tikz. Below is an MWE:

\documentclass[tikz]{standalone}
\tikzset{%
pics/abc/.style={%
code={
\node {this is some path};
}
}
}
\begin{document}
\begin{tikzpicture}
%local bounding box failed
\foreach \i in {1,2} \pic[local bounding box=\i] at (0,\i) {abc};
\draw(1)circle(1);

%local bounding box successful
\pic[local bounding box=3] at (10,4) {abc};
\draw(3)circle(1);

\end{tikzpicture}
\end{document}


When I produce the local bounding box (1) and (2) using \foreach and \pic, \draw(1)circle(1); will cause error. But when I produce the local bounding box (3) directly using \pic without \foreach, \draw(3)circle(1); will be all right. Thanks very much for any help!

You need braces and may want to add the /.expanded key. I made several additional changes to "modernize" your code.

\documentclass[tikz]{standalone}
\tikzset{%
pics/abc/.style={%
code={
\node {this is some path};
}
}
}
\begin{document}
\begin{tikzpicture}
%local bounding box failed
\path foreach \i in {1,2} {(0,\i) pic[local bounding box/.expanded=\i]  {abc}};