This is a follow up to comments between the OP and myself.
Since full code was not provided and since I don't really know tikz at all, I grabbed another answer of mine at \foreach problem and show how to insert arguments from readarray package's \getargC macro into both \draw and \node macros, using the loop index as the argument.
Given an earlier call to \getargsC{15 43 35 21 1}, the particular stretch of code where that is used is
\foreach \y in {1,2,...,\the\numexpr\CylGrad-1}
{\draw[semithick] (0,\y/\CylGrad)
arc (270:260:1 and \CylRatio) ;
\draw[semithick] (0,\y/\CylGrad)
arc (270:280:1 and \CylRatio) (0.2,\y/\CylGrad)
node[right,yslant=\CylRatio](\y){\footnotesize \myarg{\y}};% <--\myarg used here
\node at (0,\y/\CylGrad){\myarg{\numexpr\y+1}};}; % <--\myarg used here
\fi
Here is the full MWE.
\documentclass[tikz]{standalone}
\usepackage{readarray}
\def\myarg#1{\csname arg\romannumeral#1\endcsname}
\pgfkeys{/tikz/.cd,
CylCol/.store in=\CylCol,
CylCol=gray,
CylFillCol/.store in=\CylFillCol,
CylFillCol=blue,
CylFill/.store in=\CylFill,
CylFill=0,
CylRatio/.store in=\CylRatio,
CylRatio=.08,
CylGrad/.store in=\CylGrad,
CylGrad=5,
CylSecondGrad/.store in=\CylSecondGrad,
CylSecondGrad=0,
}
\newcommand{\TikzCylindre}[1][]{%
\begin{scope}[#1]
% Grisé des surfaces du cylindre.
\shade[left color=\CylCol!30, right color=\CylCol!5]%
(-1,1)--(-1,0) arc (180:360:1 and \CylRatio) --(1,0) -- (1,1);
\shade[left color=\CylCol!5, right color=\CylCol!30]%
(0,1) ellipse (1 and \CylRatio);
\draw[\CylCol!50] (1,0) arc (0:180:1 and \CylRatio)--(-1,0) ;
% Remplissage du cylindre
\shade[left color=\CylFillCol!40, right color=\CylFillCol!10]%
(-1,\CylFill)--(-1,0) arc (180:360:1 and \CylRatio) --(1,0) -- (1,\CylFill);
\fill[color=\CylFillCol!25] (0,\CylFill) ellipse (1 and \CylRatio);
\draw[\CylFillCol!50!black!50] (1,0) arc (0:180:1 and \CylRatio)--(-1,0) ;
\draw[\CylFillCol!50!black!50] (0,\CylFill) ellipse (1 and \CylRatio) ;
% dessin des bords du cylindre
\draw[semithick] (-1,1)--(-1,0) arc (180:360:1 and \CylRatio)--(1,0)--(1,1);
\draw[semithick] (0,1) ellipse (1 and \CylRatio);
\begin{scope}[shift={(0,-\CylRatio)}]
\ifnum\CylGrad>0
\foreach \y in {1,2,...,\the\numexpr\CylGrad-1}
{\draw[semithick] (0,\y/\CylGrad)
arc (270:260:1 and \CylRatio) ;
\draw[semithick] (0,\y/\CylGrad)
arc (270:280:1 and \CylRatio) (0.2,\y/\CylGrad)
node[right,yslant=\CylRatio](\y){\footnotesize \myarg{\y}};% <--\myarg used here
\node at (0,\y/\CylGrad){\myarg{\numexpr\y+1}};}; % <--\myarg used here
\fi
\ifnum\CylSecondGrad>0
\foreach \y in {1,2,...,\the\numexpr\CylSecondGrad}
{\draw(0,\y/\CylSecondGrad) arc (270:265:1 and \CylRatio) ;
\draw (0,\y/\CylSecondGrad) arc (270:275:1 and \CylRatio) ;
};
\fi
\end{scope} ;
\end{scope}
}
\begin{document}
\getargsC{15 43 35 21 1}
\begin{tikzpicture}
\TikzCylindre[x=1.5cm,y=4cm,CylFill=.8,CylSecondGrad=10] ;
\end{tikzpicture}
\end{document}

\getargsC{}macro of thereadarraypackage (see http://tex.stackexchange.com/questions/2132/how-to-define-a-command-that-takes-more-than-9-arguments/99271#99271) allows a list of space-separated arguments that get placed into\argi,\argii,\argiii, etc. in roman numeral format. – Steven B. Segletes Apr 18 '16 at 16:41\csname arg\romannumeral 27\endcsname, which you can implement as\def\myarg#1{\csname arg\romannumeral#1\endcsname}and invoke as\myarg{27}. – Steven B. Segletes Apr 18 '16 at 18:21\foreachexpert, and you have not provided a complete length of code to compile. That said, I can do things like\foreach \y in {1,2,...,\the\numexpr\myarg{2}-1}successfully, followed by a\drawthat uses\y. – Steven B. Segletes Apr 18 '16 at 20:08