# Writing on pst-solides3D cylinders in a loop

I'm trying to create and label cylinders with pst-solides3d in a loop. The label should contain the actual counter number of the loop. Therefore I try to name the cylinders with the running number and then refer to that name. I don't think that this is a pure pst-solides3d issue, but probably the same with "normal" pstricks or even TikZ.

So far I tried defining a counter, a macro and a latex3 macro for solving the problem, but neither of them worked. In the code below I show what I have done exactly so far.

For those who don't know the pst-solides3D package, the way the text is projected on the solid is by \psProjection[object=texte, text=The text to be displayed, plan=cylPlane](0,0) where the plane the text should be displayed in is referenced by the plane's name (plan=). The plane itself is derived from the solid's surface by the following command \psSolid[object=plan, action=none, definition=solidface, args=cyl1 0, name=cylinder] where args=cyl1 0 means that the referenced object is cyl1 (=solid) and its face 0 is to be taken for deriving the plane. You can show the numbers of the solid's faces by the option numfaces=all, which you pass to the solid.

\documentclass[pstricks]{standalone}
\usepackage{pst-solides3d, expl3}

% counter
\newcounter{count}

% macro
\newcommand{\cyl}[1]{
cyl{#1}
}

\newcommand{\vPlane}[1]{
vPlane{#1}
}

% macro latex3
\ExplSyntaxOn
\def\cyl#1{cylNew{#1}}
\def\vPlane#1{vPlaneNew{#1}}
\ExplSyntaxOff

\begin{document}

% try with counter
\begin{pspicture}(-2,-6)(9,2)
\multido{\i=0+1}{4}{
\setcounter{count}{\i}
\psSolid[object=cylindre, r=.5, h=.1, name=cyl\Roman{count}](0,\i,0)
\psSolid[object=plan, action=none, definition=solidface, args=cyl\Roman{count} 0, name=vPlane\Roman{count}]
\psProjection[object=texte, text=Variant \Roman{count}, plan=vPlane\Roman{count}](0,0)
}
\end{pspicture}

% try with macro
\begin{pspicture}(-2,-6)(9,2)
\multido{\i=0+1}{4}{
\psSolid[object=cylindre, r=.5, h=.1, name=\cyl{\i}](0,\i,0)
\psSolid[object=plan,action=none, definition=solidface, args=\cyl{\i} 0, name=\vPlane{\i}]
\psProjection[object=texte, text=Variant, plan=\vPlane{\i}](0,0)
}
\end{pspicture}

% try with latex3 macro
\begin{pspicture}(-2,-6)(9,2)
\multido{\i=0+1}{4}{
\setcounter{count}{\i}
\psSolid[object=cylindre, r=.5, h=.1, name=cylNew{\i}](0,\i,0)
\psSolid[object=plan, action=none, definition=solidface, args=\cylNew{\i} 0, name=\vPlaneNew{\i}]
\psProjection[object=texte, text=Variant, plan=\vPlaneNew{\i}](0,0)
}
\end{pspicture}
\end{document}


Any suggestions how to do that?

Here is a picture of the cylinders (without labels).

You have to use the optional argument solidmemory. Otherwise the variables are only local for each object.

\documentclass[pstricks]{standalone}
\usepackage{pst-solides3d}
\begin{document}

\begin{pspicture}(-2,-4)(9,2)
\psset{Decran=35,viewpoint=15 40 20 rtp2xyz,solidmemory}
\multido{\i=0+1}{4}{%
\psSolid[object=cylindre, r=.5, h=0.1, name=cyl\i](0,\i,0)%
\psSolid[object=plan, action=none, definition=solidface, args=cyl\i\space 0, name=vPlane\i]%
\psProjection[object=texte, text=Variant \i, fontsize=6,plan=vPlane\i](0,0)%
}
\end{pspicture}

\end{document}


And, by the way: Your "expl3-code" has nothing to do with LaTeX3, and your example code has some errors!

• Thanks, I didn't know about the solidmemory argument so far. "Your "expl3-code" has nothing to do with LaTeX3": Do you mean that this is no latex3-syntax at all or that it's jusing the same "mechanism" under the hood as the normal macro? "your example code has some errors!": I know, but I didn't say that this was a MWE, it was just to show what I have tried to do. – Nico Jan 31 '20 at 9:09
• Yes, no LaTeX3 syntax, it's a simple TeX syntax. With ExplSyntaxOn you are able to use the LaTeX3 syntax, no more no less. – user187802 Jan 31 '20 at 10:15