Circuitikz - NC 按钮

Circuitikz - NC 按钮

我想在电路中添加一个常闭按钮示意图。我是电路初学者,我找不到如何直接操作的方法,只能通过修改...有人能帮我吗?

关闭位置

提前致谢!

答案1

我创建了一个名为 的新组件pushed button。我将pushbotton底部复制并移动到\pgf@circ@res@temp

\documentclass{standalone}
\usepackage{circuitikz}

\makeatletter
%% Push Button
\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/pushbutton/height 2}}{pushedbutton}{\ctikzvalof{bipoles/pushbutton/height}}{\ctikzvalof{bipoles/pushbutton/width}}{
    \pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}
  \pgf@circ@res@temp=-\pgfkeysvalueof{/tikz/circuitikz/nodes width}\pgf@circ@Rlen
  \advance\pgf@circ@res@temp by -2\pgfstartlinewidth
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@temp}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@temp}}
    \pgfpathmoveto{\pgfpoint{0}{\pgf@circ@res@temp}}
    \pgfpathlineto{\pgfpoint{0}{\pgf@circ@res@up}}
    \pgfusepath{draw}

    \pgftransformshift{\pgfpoint{\pgf@circ@res@left}{0pt}}
    \pgfnode{ocirc}{center}{}{}{\pgfusepath{draw}}
    \pgftransformshift{\pgfpoint{2\pgf@circ@res@right}{0pt}}
    \pgfnode{ocirc}{center}{}{}{\pgfusepath{draw}}
}
\def\pgf@circ@pushedbutton@path#1{\pgf@circ@bipole@path{pushedbutton}{#1}}
\compattikzset{pushed button/.style = {\circuitikzbasekey, /tikz/to path=\pgf@circ@pushedbutton@path, l=#1}}
\makeatother

\begin{document}
\begin{circuitikz}
\draw (0,0) to[pushed button] (2,0);
\end{circuitikz}
\end{document}

演示

相关内容