12

I can draw lines in Inkscape (with Bezier tool or freehand line tool), but they appear as path objects and when I save it, in the svg file they are also appear as path. My question is: How can I draw and save lines as line and not as path with Inkscape?

  • Hi. Welcome to GDSE. Can I ask why you want to do that? What do you hope to gain? What specifically are you trying to do? – Billy Kerr Apr 7 at 14:26
  • @BillyKerr I guessed he wants to give some input to some already existing program which expects SVG line commands. – user287001 Apr 7 at 14:30
  • 1
    But that can solve the problem , if the questioner has a possiblity to run Illustrator. Add it to your answer! – user287001 Apr 7 at 14:47
  • 1
    @user287001 - well this is weird. Inkscape sees a line segment, but there's no way to create one! See example line segment imported from Illustrator – Billy Kerr Apr 7 at 14:48
  • 2
    Sorry for the late reply. As user287001 mentioned I have to give SVG as an input and it expects lines. I was wondering if Inkscape can create lines, since it sees lines and if you open an SVG containing lines, you can modify it and save it, and it remains line. – Zoltán Apr 7 at 15:18
12

TLDR: You can't really, but you can kind of*

In Inkscape lines, or shapes (except for rectangles**), are generally constructed using the concept of vector paths, to which fills and strokes are applied. That's how the software works. There's no Line Segment Tool in Inkscape, like the one in Illustrator.

*It is possible to link or embed raster images in Inkscape and other vector image editors, but these will remain as raster images made of pixels. It's also possible to rasterize objects made in Inkscape using Edit > Make Bitmap Copy, but again these will then be made of pixels, and not vector.

*Also, you could use underscore characters to make a line, which would of course be a text object, rather than a path. But then again, strictly speaking, fonts are still made of vector paths.

**Also possible is to create a long rectangle, and fill it. Technically not a path as such, but an SVG rect object, as you will see if you examine the XML code.

Edit: further to the comments with user287001, it would seem there are other possibilities. Illustrator has a Line Segment Tool, and a line made with it, and exported as SVG, will create an SVG line object. Another possibility is to hand code the line segment. Shouldn't be too hard to hack it. And strangely enough Inkscape can see these SVG elements if you open such an SVG in Inkscape.

Here's an example SVG line segment that seems to work in Inkscape, you just can't create one with a tool, nor edit the end points with a tool using the GUI. You can rotate it, and stretch it though.

  <line
 x1="37.770248"
 y1="32.135063"
 x2="80.329521"
 y2="18.314875"
 id="line1"
 style="fill:none;stroke:#231f20;stroke-width:0.48102528;stroke-miterlimit:10" />
  • 1
    If anyone wants to request this feature, here is the page where you can do so. I would do it myself, but I'm not sure I understand the use case well enough. – Wildcard Apr 9 at 17:19
  • I was trying to find that page for the OP, but failed to do so. Thanks so much for sharing the link! – Billy Kerr Apr 9 at 18:43
6

Inkscape seems to create XML code for a path even if you draw a straight line segment with the pen tool in straight line mode. I guess some programming is needed either for converting path commands to SVG line commands or for creating a drawing tool which creates internally SVG line expressions.

Unfortunately I cannot show such Inkscape extension program and even less I can make one. But check this discussion in the sister site: https://stackoverflow.com/questions/9102563/turn-svg-path-into-line-segments

A quick search popped out also this code. https://jsfiddle.net/fq9n7f76/18/

I must admit I cannot see is it valid, but it seems to ouput polylines. Hopefully you can read and speak this language better.

Some CAD programs can export the wanted SVG lines. I have checked that at least LibreCAD does it because some CAM-tools want it. LibreCAD is freeware. Check, if you can do your drawing work there.

  • Thanks for your answer. Yes, I can speak that language, since I'm a programmer not a designer :) – Zoltán Apr 7 at 15:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.