Inkscape.org
Using Inkscape with Other Programs Confusion about the <path> d attribute
  1. #1
    HenryInUtah HenryInUtah @HenryInUtah

    Hello,

    I am writing a Python program that reads paths from an Inkscape SVG and then uses them for some wonderful purpose.  Here is the <path> that I am using for testing:

        <path
           style="fill:none;stroke:#000000;stroke-width:2;stroke-dasharray:none;stroke-opacity:1"
           d="m 381.63838,204.04428 -17.00369,80.2952 141.69741,80.29521 53.84502,-101.07749 z"
           id="path15"
           inkscape:label="S1" />

     This path basically looks like a rectangle.  However, when I connect the "points" in the path attribute it looks more like an arrowhead.  I have no idea how Inkscape can create a rectangle type of shape from this.  I tried the points in a Python program and also a CAD package and the result is the same.  Not what I see in Inkscape.

    What am I missing?

    Point 1 -> 381.63838,204.04428

    Point 2 -> -17.00369,80.2952

    Point 3 -> 141.69741,80.29521

    Point 4 -> 53.84502,-101.07749

     

    Thank for your help.

  2. #2
    inklinea inklinea @inklinea⛰️

    It's svg in general rather than Inkscape.

    Path commands can be relative (lower case) or absolute (upper case).

    They can also be mixed.

    Generally it will follow from the last case, so it you start with 'm' and there are no other letter commands until 'z' (zone close, which doesn't matter if is upper or lower Z, z), then it will be assume relative throughout.

    In the XML editor try changing m to M and vice versa. 

    You can also put l or L in front of each point pair. 

    It may be that you are changing the case in your code somewhere ? 

  3. #3
    HenryInUtah HenryInUtah @HenryInUtah

    Thank you!  That explains it. 

    I understand why a person writing svg by hand might want to interchange absolute and relative, but it seems odd that a computer would do that.  But it doesn't matter.  At least I can sleep at night because I understand :)

    Thanks again.