tikz pgf add tag
Anonymous 13902
This question has been cross-posted to [tex.stackexchange.com](https://tex.stackexchange.com/q/752610/2288).

I would like to know how to properly define a custom style key `topstyle` inside the family `my cylinder parameters` and apply it to any pic instance.

The following produces the error 

> Package xcolor Error: Undefined color `fill=red'

```
\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usepackage{tikz-3dplot}

\tikzset{
	my cylinder parameters/.is family,
	my cylinder parameters,
	radius/.store in = \cylRadius, radius=1,
	height/.store in = \cylHeight, height=2,
	rotation/.store in = \cylRotation, rotation=0,
	color/.store in = \cylColor, color=blue,
	topstyle/.store in = \cylTopStyle,
	topstyle = {fill=\cylColor!20, fill opacity=0.1},
	topstyle/.default = {fill=\cylColor!20, fill opacity=0.1},
}

\tikzset{
	pics/mycylinder/.style = {
		code = {
			\tikzset{my cylinder parameters, #1}
			\tikzset{/my cylinder parameters/.cd}
			
			\begin{scope}[tdplot_main_coords]				
				\draw[thick, \cylTopStyle] (0,0,\cylHeight) circle(\cylRadius);
			\end{scope}
		}
	}
}

\begin{document}
	
	\newcommand{\rotX}{60}
	\newcommand{\rotZ}{40}
	
	\tdplotsetmaincoords{\rotX}{\rotZ}
	
	\begin{tikzpicture}[tdplot_main_coords]
		\pic at (2,0,0) {mycylinder={color=red}};
		\pic at (0,0,0) {mycylinder={color=red, topstyle}};
		\pic at (-2,0,0) {mycylinder={color=red, topstyle = {fill=green}}};
	\end{tikzpicture}
\end{document}
```

This room is for discussion about this question.

Once logged in you can direct comments to any contributor here.

Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.