[Tex/LaTex] Replacement for \curveto in the tikz library – Inkscape export svg to tikz

inkscapepstrickssvgtikz-pgf

I need to draw a complex curve and I wanted to help a vector program Inkscape.
In first step I tried to use Inkscape to TikZ exporter (http://code.google.com/p/inkscape2tikz/)to convert curve to tikz, but unsuccessfully (error occured after start of the plugin – Inkscape 0.48.2 r9819/Extension/Export/Export to Tikz path). It is unlikely that someone with me to help with this error:

    Traceback (most recent call last):

  File "tikz_export.py", line 1391, in <module>

    main_inkscape()

  File "tikz_export.py", line 1379, in main_inkscape

    effect.affect()

  File "C:\Program Files (x86)\Inkscape\share\extensions\inkex.py", line 216, in affect

    if output: self.output()

  File "tikz_export.py", line 1322, in output

    f = codecs.open(self.options.outputfile, 'w', 'utf8')

  File "C:\Program Files (x86)\Inkscape\python\Lib\codecs.py", line 870, in open

    file = __builtin__.open(filename, mode, buffering)

IOError: [Errno 13] Permission denied: 'none'

So I would like to ask how could be replaced command \curveto by native tikz command. Because I'm able to convert Inkscape curve to PSTricks… I'm more familiar with pakcage tikz.

%LaTeX with PSTricks extensions
%%Creator: 0.48.2
%%Please note this file requires PSTricks extensions
\psset{xunit=.5pt,yunit=.5pt,runit=.5pt}
\begin{pspicture}(272,129)
{
\newrgbcolor{curcolor}{0 0 0}
\pscustom[linewidth=1,linecolor=curcolor]
{
\newpath
\moveto(1.410771,63.47461)
\curveto(6.288991,93.43519)(6.900971,94.37507)(27.182131,102.49149)
\curveto(41.727261,108.31238)(35.032981,125.42937)(51.364001,125.36952)
\curveto(67.695031,125.30962)(67.928601,83.44326)(69.419751,64.22647)
\curveto(70.630951,48.61748)(74.370481,32.72818)(94.65164,24.61178)
\curveto(109.19677,18.79088)(101.39868,1.81368)(117.97023,1.87438)
\curveto(134.06073,1.93338)(134.11602,42.07748)(136.03504,63.349)
\curveto(136.94551,73.44118)(139.86205,86.13389)(143.15997,91.12848)
\curveto(146.45789,96.12308)(151.68117,98.38715)(161.82175,102.44536)
\curveto(176.36688,108.26625)(169.6726,125.38324)(186.00362,125.32339)
\curveto(202.33465,125.26349)(199.36351,96.7115)(204.05937,64.18034)
\curveto(208.75523,31.64918)(209.0101,32.68208)(229.29126,24.56568)
\curveto(243.83639,18.74478)(236.0383,1.76758)(252.60985,1.82828)
\curveto(268.70035,1.88728)(256.58629,30.46878)(270.65931,63.2234)
}
}
\end{pspicture}

I guess it could solve command control, but I still have not succeeded.

Thanks.

Best Answer

(It looks like Inkscape couldn't open a file for writing to.)

The following "works" with your example. If all your generated code is like that then it might work with that, but it isn't a full solution.

The direct replacement for \curveto is \pgfpathcurveto. So you could redefine the PSTricks macros to their PGF equivalents (where such exist) as follows:

\documentclass{article}
%\url{http://tex.stackexchange.com/q/82308/86}
\usepackage{tikz}

\def\moveto(#1,#2){%
  \pgfpathmoveto{\pgfpoint{#1 pt}{#2 pt}}}

\def\curveto(#1,#2)(#3,#4)(#5,#6){%
  \pgfpathcurveto{\pgfpoint{#1 pt}{#2 pt}}{\pgfpoint{#3 pt}{#4 pt}}{\pgfpoint{#5 pt}{#6 pt}}}

\let\psset=\tikzset
\def\pscustom[#1]{\tikzset{#1}}
\tikzset{
  xunit/.style={x={(#1,0)}},
  yunit/.style={y={(0,#1)}},
  runit/.style={},
  linecolor/.style={color=#1},
  linewidth/.style={line width=#1},
}

\def\newrgbcolor#1#2{\definecolor{#1}{RGB}{#2}}
\def\pspicture(#1,#2){\tikzpicture}
\def\endpspicture{%
\pgfusepath{stroke}
\endtikzpicture}
\let\newpath=\relax


\begin{document}

%LaTeX with PSTricks extensions
%%Creator: 0.48.2
%%Please note this file requires PSTricks extensions
\psset{xunit=.5pt,yunit=.5pt,runit=.5pt}
\begin{pspicture}(272,129)
{
\newrgbcolor{curcolor}{0 0 0}
\pscustom[linewidth=1,linecolor=curcolor]
{
\newpath
\moveto(1.410771,63.47461)
\curveto(6.288991,93.43519)(6.900971,94.37507)(27.182131,102.49149)
\curveto(41.727261,108.31238)(35.032981,125.42937)(51.364001,125.36952)
\curveto(67.695031,125.30962)(67.928601,83.44326)(69.419751,64.22647)
\curveto(70.630951,48.61748)(74.370481,32.72818)(94.65164,24.61178)
\curveto(109.19677,18.79088)(101.39868,1.81368)(117.97023,1.87438)
\curveto(134.06073,1.93338)(134.11602,42.07748)(136.03504,63.349)
\curveto(136.94551,73.44118)(139.86205,86.13389)(143.15997,91.12848)
\curveto(146.45789,96.12308)(151.68117,98.38715)(161.82175,102.44536)
\curveto(176.36688,108.26625)(169.6726,125.38324)(186.00362,125.32339)
\curveto(202.33465,125.26349)(199.36351,96.7115)(204.05937,64.18034)
\curveto(208.75523,31.64918)(209.0101,32.68208)(229.29126,24.56568)
\curveto(243.83639,18.74478)(236.0383,1.76758)(252.60985,1.82828)
\curveto(268.70035,1.88728)(256.58629,30.46878)(270.65931,63.2234)
}
}
\end{pspicture}

\end{document}

PGF Path

What I would do in such a circumstance is actually use something like the above to generate a pgf soft path, then cut-and-paste that into my real document. I wouldn't use hacks like the above in a proper document.

Related Question