Circuitikz の新しいコンポーネント

Circuitikz の新しいコンポーネント

回路図で使用する新しい要素を作成したいと考えています。これまで回路図には CircuiTikz を使用してきましたが、標準要素を定義する低レベルの PGF コマンドには精通していません。図に描いたような単純なコンポーネントを作成する最も簡単な方法は何でしょうか。ただし、回路図の残りの部分にそれを含めることができる必要があります。

成分

新しい要素を接続する回路のコード:

\documentclass[tikz,border=10pt]{standalone}
\usepackage{tikz}
\usepackage{circuitikz}

\begin{document}
    \begin{circuitikz}[scale=0.75, american inductors, american voltages, european resistors]
        \draw
        (0,3.5) to[short] (0.5,4) to[short] (1,4) to[L] (3,4) to[short] (6,4)
        (0,3.5) to[short] (0.5,3.5) to[short] (1,3.5) to[L] (3,3.5) to[short] (6,3.5)
        (0,3.5) to[short] (0.5,3) to[short] (1,3) to[L] (3,3) to[short] (6,3);

        \draw
        (0,3.5) to[short, *-] (0,2)
        to[R] (0,0)
        node[ground] {};
        %I want to connect the new component here at the red dot!
        \filldraw[fill=red] (0,2.5) circle (0.2);

    \end{circuitikz}
 \end{document}

ここに画像の説明を入力してください

赤い点で接続したいです。

答え1

こんな感じでしょうか?これはJohn Kormylo のバイポールチュートリアル:

ここに画像の説明を入力してください

\documentclass[tikz,border=10pt]{standalone}
\usepackage{tikz}
\usepackage{circuitikz}

\makeatletter
% used to process styles for to-path
\def\TikzBipolePath#1#2{\pgf@circ@bipole@path{#1}{#2}}
% restore size value for bipole definitions
\pgf@circ@Rlen = \pgfkeysvalueof{/tikz/circuitikz/bipoles/length}
\makeatother
\newlength{\ResUp}
\newlength{\ResDown}
\newlength{\ResLeft}
\newlength{\ResRight}

% newcomponent
\ctikzset{bipoles/newcomponent/height/.initial=.50}   % box height
\ctikzset{bipoles/newcomponent/width/.initial=.50}    % box width
\pgfcircdeclarebipole{}                               % no extra anchors
{\ctikzvalof{bipoles/newcomponent/height}}
{newcomponent}                                        % component name
{\ctikzvalof{bipoles/newcomponent/height}}
{\ctikzvalof{bipoles/newcomponent/width}}
{                                                     % component symbol drawing...
  \pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}
  \pgfextracty{\ResUp}{\northeast}                    % coordinates
  \pgfextracty{\ResDown}{\southwest}
  \pgfextractx{\ResLeft}{\southwest}
  \pgfextractx{\ResRight}{\northeast}
  \pgfpathmoveto{\pgfpoint{\ResDown}{\ResRight}}      % two arc's
  \pgfpatharc{90}{-90}{\ResRight/2}
  \pgfpatharc{90}{-90}{\ResRight/2}
  \pgfpathmoveto{\pgfpoint{\ResUp}{\ResLeft}}         % another two arc's
  \pgfpatharc{90}{-90}{\ResLeft/2}
  \pgfpatharc{90}{-90}{\ResLeft/2}
  \pgfusepath{draw}                                   % draw it!
}
\def\circlepath#1{\TikzBipolePath{newcomponent}{#1}}
\tikzset{newcomponent/.style = {\circuitikzbasekey, /tikz/to path=\circlepath, l=#1}}


\begin{document}
    \begin{circuitikz}[scale=0.75, american inductors, american voltages, european resistors]
        \draw
        (0,3.5) to[short] (0.5,4) to[short] (1,4) to[L] (3,4) to[short] (6,4)
        (0,3.5) to[short] (0.5,3.5) to[short] (1,3.5) to[L] (3,3.5) to[short] (6,3.5)
        (0,3.5) to[short] (0.5,3) to[short] (1,3) to[L] (3,3) to[short] (6,3);

        \draw
        (0,3.5) to[short, *-] (0,2)
        to[newcomponent] (0,0)                       % connect the new component
        to[R] (0,-2)
        node[ground] {};
    \end{circuitikz}
\end{document}

関連情報