edit:
I believe the TikZ key external/mode=graphics if exists
does exactly what you want. (See the TikZ/PGF Manual v2.10 Section 32.4.4, page 349.) Try the following for your example:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{external}
\tikzexternalize
\tikzset{external/mode=graphics if exists}
\begin{document}
\def\mypic#1{
\begin{tikzpicture}\clip (-1,-1) rectangle (1,2);
\draw[red] plot (\x,{#1});
\end{tikzpicture}
}
\mypic{(\x)^2}
\begin{tikzpicture}\clip (-1,-1) rectangle (1,2);
\draw[red] plot (\x,{\x*\x*\x});
\end{tikzpicture}
\end{document}
original answer:
If you know that the external graphics has a particular extension (as seems to be given in your case) you can use \IfFileExists{<file>}{}{}
, e.g.
\documentclass{article}
\usepackage{tikz}
\begin{document}
\IfFileExists{./logo.pdf}{%
\includegraphics{logo}
}{%
\begin{tikzpicture}
\draw (0,0) rectangle (1,1);
\end{tikzpicture}
}
\end{document}
Welcome to TeX.SE!!
Here is a solution. Basically, I use the TikZ 3d library to define a vertical rotated canvas
inside a scope
. Then, in the scope I draw the rectangles and the arcs
. Of course I need to do this three times, one for each plane. The last thing to draw are the nodes (balls), this way they don't interfere with the visibility.
Something like this:
\documentclass[tikz,border=2mm]{standalone}
\usetikzlibrary{3d,perspective}
\tikzset
{
my rectangle/.style={dotted,fill=white,fill opacity=0.5},
my node/.style={circle,draw,shading=ball,ball color=yellow}
}
\begin{document}
\begin{tikzpicture}[isometric view,line cap=round,line join=round]
% coordinates
\foreach[count=\j]\i in {1,3,5,7,9}
\coordinate (\j) at (0,0,\i);
% blue plane
\begin{scope}[rotate around z=10,canvas is xz plane at y=0,blue]
\draw[my rectangle] (0,0) -| (5,10) -- (0,10);
\foreach\i in {2,3}
\draw[thick] (\i) arc (-90:90:5-\i);
\end{scope}
% green plane
\begin{scope}[rotate around z=135,canvas is xz plane at y=0,,green!50!black]
\draw[my rectangle] (0,0) -| (5,10) -- (0,10);
\foreach\i in {1,2,3,4}
\pgfmathsetmacro\j{\i+1}
\draw[thick] (\i) arc (-90:90:1);
\draw[thick] (1) arc (-90:90:4);
\draw[thick] (2) arc (-90:90:2);
\end{scope}
% red plane
\begin{scope}[rotate around z=255,canvas is xz plane at y=0,red]
\draw[my rectangle] (0,0) -| (5,10) -- (0,10);
\foreach\i in {2,3}
\draw[thick] (1) arc (-90:90:\i);
\end{scope}
% nodes / balls
\draw[dotted,thick] (0,0,-1) -- (0,0,11);
\foreach\i in {1,...,5}
\node[my node] at (\i) {};
\end{tikzpicture}
\end{document}
![enter image description here](https://i.stack.imgur.com/V7OHC.png)
Best Answer
There are several programs to plan and construct a model railway. And it seems you know at last one of them. One advantage of them is that they can print a list of used parts to build the model railway.
To create the layouted plan with TikZ you have to write a new code to layout the plan with TikZ. That is not easy and a lot of work (as also @MartinH said in his comment).
I personaly think it makes no sense to recreate that. Better is to use the existing program and include the result with
\includegraphics
. If you have problems with the quality of the picture change the format in the planing software for saving the plan (to.jpg
,.pdf
,.epc
). If that is not possible consider to change the planing program for the model railway.