I've looked at this and that, and I'm unable to compile and use intersections of lines i give name inside the same foreach loop.
\documentclass[tikz]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc,intersections}
\begin{document}
\begin{tikzpicture}
\pgfmathsetmacro{\xsidelength}{2}
\pgfmathsetmacro{\ysidelength}{1.5}
\path[draw, dashed,name path global=star2] (0,0) --
++(\xsidelength,0) --
++(45:\ysidelength) --
++(-\xsidelength,0) --
cycle;
\pgfmathsetmacro{\halfylength}{\ysidelength/2}
\coordinate (O) at ($(\xsidelength / 2,0)+(45:\halfylength)$);
\node[draw, circle, inner sep=1pt] at (O) {};
\foreach \angle[count=\i] in {22.5,0,...,-225}
{
\path[name path global/.expanded=line\i] (O) -- ++(\angle:\xsidelength);
\draw[name intersections = {of {line\i} and star2}](intersection\i) circle (2pt);
}
\end{tikzpicture}
\end{document}
The first path is drawn, but its name is apparently not known inside the foreach, nor lines defined just a line above
And I've got next errors
:26: Package pgfkeys Error: I do not know the key '/tikz/intersection/of {line1} and star2' and I am going to ignore it. Perhaps you misspelled it.
:26: Package tikz Error: I do not know the path named `'. Perhaps you misspelt it.
:26: Package pgf Error: No shape named intersection1 is known.
Though, the example is not really minimal, I don't see what is different from answered questions, except i'm trying to reuse names inside the same foreach