Motivation
I have a document in which I draw dashed lines. Ultimately, I want to use it for a laser-cutting project which needs to cut the lines in a dashed fashion.
In TikZ, I define the paths (straight lines, arcs, etc.) with a special style:
In preamble:
\tikzset{LaserCutterOutlineCut/.style={dash pattern=on 20pt off 1 pt}}%
\newcommand*{\LaserCutterLineWidth}{0.04cm}
In a figure (assuming the (x1,y1) and (x2,y2) points are defined above):
\draw[style=LaserCutterOutlineCut,line width=\LaserCutterLineWidth] (x1,y1) rectangle (x2,y2);
The Problem
When I run pdflatexmk through TexShop, it creates a PDF that looks awesome. When I import the PDF in Adobe Illustrator, the path is a single path with appropriate dashed lines. However, when I export it to a different format that the laser-cutter can use, the laser cutter sees it as a single, solid path — the dashed metadata is stripped away.
My Question
Is there a way to force TikZ to render a given dashed path as a series of paths according to the specified dashed line style instead of rendering it as a single path?
If it doesn't exist, I can think of a workaround: one could write one or more wrapper functions and redefine the original functions such that whenever one draws a rectangle or arc or circle (etc.) in a dashed line style, it calls the wrapper function instead. The wrapper function then would iterate in a for loop and instead draws a series of paths. Unfortunately, the syntax needed for that is several steps beyond my current understanding.


decorationmakes individual paths. Do my answer work? I am not happy with my answer! It can be made better, but I need to know more. Please see my questions. – hpekristiansen Jul 14 '21 at 17:55