[Tex/LaTex] How to get line width and inner sep values

key-valuepgfkeystikz-pgftikz-styles

I try to get the values of line widths and node inner sep. How to read such a value form own style (if it will be specified during modifications of the picture) or if it is not specified in this style, how to get the value applied by drawing line or node?

Code:

\documentclass{standalone}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}[
    every node/.style={line width=2pt},
    my line style/.style={very thick},
    my node style1/.style={draw,inner sep=1em},
    my node style2/.style={draw}
]
    \pgfkeys{/pgf/inner xsep/.get=\innerxsep}
    \node at (0,0) [my node style2,anchor=west] {x inner sep = \innerxsep};

    %\pgfkeys{ ????  /.get=\innerxsep} % how to read inner sep value applied while "my node style1" is used,
                                       % independently on if it is specified in this style?
                                       % how to read border width value applied while "my node stylei" is used,
                                       % independently on if it is specified in this style?
    \node at (0,-1) [my node style1,anchor=west] {x inner sep = ?, border width = ?};

    %\pgfkeys{ ????  /.get=\lw} % how to read line width value applied while "my line style" is used,
                                % independently on if it is specified in this style?
    \draw [my line style] (0,-2) -- +(1,0) node [right] {line width=?};
\end{tikzpicture}
\end{document}

I tried follow answers given by @Loop Space (Reading – and effect – of (default) tikz/pgf keys?) and by @Andrew Swann (Check the value of a pgfkey), but without success in my problem.

Best Answer

Your own style doesn't change any intrinsic properties of the line width and inner sep settings. So you can still use the regular key setting/reading ways.

\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}[
    every node/.style={line width=2pt},
    my line style/.style={very thick},
    my node style1/.style={draw,inner sep=1em},
    my node style2/.style={draw}
]
    \node at (0,0) [my node style2,anchor=west] 
         {x inner sep = \pgfkeysvalueof{/pgf/inner xsep}};
    \node at (0,-1) [my node style1,anchor=west] 
         {x inner sep = \pgfkeysvalueof{/pgf/inner xsep}, border width = \the\pgflinewidth};
    \draw [my line style] (0,-2) -- +(1,0) node [right] {line width=\the\pgflinewidth};
\end{tikzpicture}
\end{document}

enter image description here