You can read from files in TeX. Presume you have a file foo
with content (0,0) -- (2,0) -- (2,2)
Then you can read that line and pass it to a draw command as follows:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\newread\bar
\openin\bar=foo
\read\bar to\res
\tikz\draw\res;
\end{document}
And that will draw the corresponding lines. If you have multiple lines in a file then \read\bar to \res
a second time will read the second line from the file. After you are done with it, you should \closein\bar
. There is also an \ifeof
which you can use to loop over the file until it contains no more lines.
To go through the entire file, you can simply write a macro that loops as long as there are things to read. For this simple setup to work, the first command in the loop has to be the read of the file.
\documentclass{article}
\usepackage{tikz}
\def\myloop#1#2#3\repeat{\def\filenm{#2}\def\body{#1#2#3}\iterate}
\def\iterate{\body\ifeof\filenm\let\next\relax\else\let\next\iterate\fi\next}
\begin{document}
\newread\bar
\openin\bar=foo
\begin{tikzpicture}
\myloop\read\bar to\res\draw\res;\repeat
\end{tikzpicture}
\end{document}
This will add every line of the file to the same tikzpicture
.