# How do I make a custom node using the height of the bounding box?

I've been playing around with custom arcs, but I can't seem to figure out how to set the arc radius automatically. Goal is to create a node that bounds two semi-circles and gets wider as needed

Links to the desired image at at the end

https://i.stack.imgur.com/E4qag.jpg

\usepackage{xparse}
\NewDocumentCommand{\mynode}{%
O{}
m
m
m
O{}
}{
{
\node [#1] (#2)  at #3 {#4};

\def\ra{.3cm}

\draw  [#5]  (#2.north west) arc
[
start angle=90,
end angle=270,
] ;

\draw [#5] (#2.north east)to [in=0,out=180] (#2.north west);
\draw [#5] (#2.south east)to [in=0,out=180] (#2.south west);

\draw  [#5]  (#2.south east) arc
[
start angle=270,
end angle=450,
] ;

}
}

[![This is what I want to make]]

: https://i.stack.imgur.com/E4qag.jpg
: https://i.stack.imgur.com/iuZgn.jpg

• The linked image uses circular arcs: x radius = y radius. It is basically a rectangle with rounded corners. OTOH, if you want elliptical nodes, see tex.stackexchange.com/questions/399116/… Mar 11 at 3:25
• Thank you. I really want the circular arcs. Just can’t use a macro to calculate their radii Mar 11 at 3:35

This uses \pgfextracty etc. to get the height of the node. I also combined all your draws into one path.

\documentclass{standalone}
\usepackage{tikz}
\usepackage{xparse}
\newlength{\mydiameter}
\NewDocumentCommand{\mynode}{% #1 = node options (optional), #2 = node name, #3 = coordinates, #4 = text, #5 = draw options (optional)
O{}
m
m
m
O{}
}{%
{%
\node [#1] (#2)  at #3 {#4};

\pgfextracty{\mydiameter}{\pgfpointdiff{\pgfpointanchor{#2}{south}}{\pgfpointanchor{#2}{north}}}%

\draw  [#5]  (#2.north west) arc
[
start angle=90,
end angle=270,
] -- (#2.south east) arc
[
start angle=-90,
end angle=90,
] -- cycle;
}%
}

\begin{document}
\begin{tikzpicture}
\mynode{A}{(0,0)}{Test}
\end{tikzpicture}
\end{document} • wow perfect! thank you. good clean example. Mar 11 at 16:27