Novo componente no circuitikz

Novo componente no circuitikz

Quero criar um novo elemento para usar em um diagrama de circuito. Até agora usei o CircuiTikz para o diagrama de circuito, mas não estou familiarizado com os comandos PGF de baixo nível que definem os elementos padrão. Qual seria a maneira mais fácil de criar um componente simples como o que desenhei na figura? Devo ser capaz de incluí-lo no resto do meu diagrama de circuito.

componente

Código para o circuito ao qual desejo conectar o novo elemento:

\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}

insira a descrição da imagem aqui

Quero conectá-lo no ponto vermelho.

Responder1

Algo assim? É baseado emTutorial bipolar de John Kormylo:

insira a descrição da imagem aqui

\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}

informação relacionada