# How do I store the x or y value of a named node in tikz \draw?

A big part of the question above has already been answered: "Use the calc tikzlibrary and the let syntax".

\begin{tikzpicture}
\draw [help lines] (0,0) grid (4,4);
\node (A) at (2,1) {A};
\path let \p1 = (A) in node  at (\x1,3) {B};
\end{tikzpicture}


But it leaves out something else. How do I use the let syntax inside a \draw directive? Like so:

\draw
(5,0) node(A){}
let \p1 = A     % This line borks everything. What is the right thing to do?
(0,5) -- (\x1,5)
;


Hoping this solution does understand your objective. It seems that given node A you wish to draw a line from (0,5) to (\x1,5), where \x1 is the coordinate of A. And you want this be done in one draw directive. That is from A to B in this demonstration.

The let command saves coordinate of A and one can use (\x1,\y1) later. Code

\documentclass{article}
\usepackage[margin=1cm]{geometry}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}

\begin{tikzpicture}
\draw  (5,0) node (A){A} let \p1 =(A) in node at (\x1,5){}  (5,0) --(\x1,5) node(B){B};
\end{tikzpicture}
\end{document}


Update: just realize the OP wants line CB, so a minor revision is given here. \begin{tikzpicture}
\draw  (5,0) node (A) {} let \p1 =(A) in node at (\x1,5){} (0,5) node(C){C} --(\x1,5) node(B) {B};
\end{tikzpicture}