2

Using Inkscape 0.92.4, is there a way to have a dashed line of whatever length in which both ends have the drawn part of the pattern? Like the length of the dashes varies a bit from the one chosen to have an integer uneven number of segments.

2

TL;DR: No, but there are some hacks.

I'm not sure how useful they will be for your particular use case, but here goes:

As far as I know, there is no way to make the stroke-dasharray change dynamically as you adjust the length of the line, at least not by moving an end node.

However, you can edit the stroke-dasharay in the XML editor manually.

For example, a stroke-dasharay of 16 and 5 (total 20) will fit 5 times in a line of length 100 units.

enter image description here

Once you have a dash that fits a line, you can group (Ctrl+G) the line, then stretch it with the Select and Transform Objects tool (F1), and the dashes and gaps will stretch. This is achieved by adding a Matrix Transform to the group, it doesn't change the stroke-dasharay.

Example

enter image description here

Note: When you ungroup the line, the Matrix Transform will be released.

3
  • I think it could be faster to change the line length with the node tool until it fits, instead of using the xml editor, then using the selection tool to stretch it with the option to 'scale stroke width when object is scaled' on.
    – Moini
    Feb 3 '20 at 12:10
  • 1
    @Moini - Sure, but then using the xml editor to edit the stroke-dasharay avoids the need to eye-ball it. Ultimately it depends on how much precision the OP wants. Perhaps you should write an answer. There's always more than one way to skin a cat!
    – Billy Kerr
    Feb 3 '20 at 12:21
  • I can set some custom stroke-dasharray on the XML editor (that is enough for my needs) but the grouping doesn´t work for me. The number of dashes change as I stretch the line. Feb 9 '20 at 14:31

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.