Neue Komponente in circuitikz

Neue Komponente in circuitikz

Ich möchte ein neues Element zur Verwendung in einem Schaltplan erstellen. Bisher habe ich CircuiTikz für den Schaltplan verwendet, bin aber mit den PGF-Befehlen auf niedriger Ebene, die die Standardelemente definieren, nicht vertraut. Was wäre der einfachste Weg, um eine einfache Komponente wie die in der Abbildung gezeichnete zu erstellen? Ich muss sie jedoch in den Rest meines Schaltplans integrieren können.

Komponente

Code für den Schaltkreis, an den ich das neue Element anschließen möchte:

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

Bildbeschreibung hier eingeben

Ich möchte es am roten Punkt anschließen.

Antwort1

So etwas? Es basiert aufJohn Kormylos Bipol-Tutorial:

Bildbeschreibung hier eingeben

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

verwandte Informationen