Inkscape Community

Help Using Inkscape => Inkscape Beginners' Questions => Topic started by: patrickonb on July 02, 2019, 06:14:49 PM

Title: Can I Create A Dashed Line With The Lines and Spaces Set To A Certain Millimeter
Post by: patrickonb on July 02, 2019, 06:14:49 PM
Hello All,

OK, I will try and make this as straightforward as I can...

I'm using Inkscape for designing my work for my laser cutter. What I need to do, is create a dashed line, with the lines and dashes
to be 2.30mm in length (or whatever else I might need). I've tried the "dashed line" option when I create a line, and click on the
"Stroke style" tab, but it doesn't work as I had hoped. Although I can choose the line to be dashes, it doesn't seem to matter that
I enter 2.30 into the "Pattern offset" input box, they do not come out to 2.30mm or any other number I put in. I thought the input
might be based on pixels and not millimeters, but even that doesn't workout properly.

I originally created a bunch of separate lines that were spaced at 2.30mm apart, but it made the laser machine do very strange things,
and it bounced all over the place as it engraved whatever random line it chose to do at any given moment! It should follow along as if
it was one continuous line, turning the laser on and off as needed for each dash, but it doesn't do that, it turns into a raging beast of
vengeance!!

Anyway, can anyone tell me if there is a way to create a dashed line, and set the spacing to whatever I need? Needs to be a consistent
2.30mm dash line, then 2.30mm dash no line, etc, etc. - - - - - -, so my laser will follow along that single path until finished, and then
move onto the next set?

Any help would be greatly appreciated!

Thanks,
Patrick
Title: Re: Can I Create A Dashed Line With The Lines and Spaces Set To A Certain Millimeter
Post by: brynn on July 02, 2019, 08:45:29 PM
Welcome to the forum!

I recall reading that a developer had started work on an LPE that would do something like that, but I don't recall hearing about it being finished or added to a new version.

Since the size and spacing seems the most important part, I would suggest just drawing the dashes as rectangles perhaps, or rectangles converted to paths.  There are plenty of ways to make the alignment precise, and  I can give specific steps, once we have all the details.  Unless this dashed line is a curved line?

If it's supposed to follow a curved path, I would probably suggest using Extensions menu > Generate from Path > Scatter.

As for the order the machine cuts them, I have no idea about that.  You'd have to search through the documentation for the machine (or its software), to find out how it decides the cutting order.  I have a suspicion that it would cut them in the order they are drawn.  Or I don't know, maybe the z-order.  The problem is that various different commands that you might use during drawing and editing, could affect that order.  Although having said that, we could probably suggest some tips that might help, depending on specifically what's happening with that unique file.

Will you be using a particular extension to prepare the file for cutting (I mean either Inkscape extension or file format extension).
Title: Re: Can I Create A Dashed Line With The Lines and Spaces Set To A Certain Millimeter
Post by: Lazur on July 03, 2019, 12:02:28 AM
Hi.

Yes and no. Maybe. Needs testing.

Dashed strokes on screen are the result of a style setting so adding a custom dasharray won't end up being recognised by the cutter.
(Nonetheless the custom dasharray is set in relation to the stroke width only so you cannot retain a certain gap-line length after changing the stroke's thickness... being the laser cutter stroke's very thin it would definitely interfere with the design process when drawing the original shapes with wider stroke thickness.)

As far as I remember there was a developed extension/lpe (?) that did separate a path into its segments, each getting a new custom dashoffset style settings. Original issue was that setting a dashed stroke to an even sided object end up being looking way off due to every side would have a different dash layout.


So the other route I'd try is using a pattern along path path effect.
That can be customized well enough  and you'd need just converting the result to path before cutting.
Title: Re: Can I Create A Dashed Line With The Lines and Spaces Set To A Certain Millimeter
Post by: Moini on July 03, 2019, 08:25:38 AM
You need to set those manually in the xml editor. Then they should in theory render correctly.
Title: Re: Can I Create A Dashed Line With The Lines and Spaces Set To A Certain Millimeter
Post by: Moini on July 03, 2019, 08:27:18 AM
https://css-tricks.com/almanac/properties/s/stroke-dasharray/
Title: Re: Can I Create A Dashed Line With The Lines and Spaces Set To A Certain Millimeter
Post by: patrickonb on July 03, 2019, 09:19:07 PM
Thanks everyone for your responses. I have opened up the XML editor, and am going to try Moini's solution.
So far, current testing is right on the money! In other words, when I put in "stroke-dasharray: 2.30;",
it certainly seems to be giving me a dashed line that is 2.30mm dash on and dash off, as I need it! Next step
will be testing this on the laser cutter tomorrow. I will let everyone know how it works out.

Thanks for the help and input, I really appreciate it!
Patrick
Title: Re: Can I Create A Dashed Line With The Lines and Spaces Set To A Certain Millimeter
Post by: patrickonb on July 04, 2019, 11:59:23 AM
OK, well it didn't work as expected. The laser simply sees it as an entire line, and ignores the
dashes as if they are not there. I'm sure this is a function of the laser machines software/hardware
setup, so no fault of Inkscapes.

Patrick
Title: Re: Can I Create A Dashed Line With The Lines and Spaces Set To A Certain Millimeter
Post by: Lazur on July 04, 2019, 02:12:44 PM
No stroke-dasharray. Use the pattern along path lpe.
Example attached.

 [ You are not allowed to view attachments ]
Title: Re: Can I Create A Dashed Line With The Lines and Spaces Set To A Certain Millimeter
Post by: brynn on July 04, 2019, 07:08:10 PM
After using XML Editor, after you set the right size/space, do Path menu > Stroke to Path.  Then it should be ready to cut.

Likewise, if you use Pattern Along Path, I think you'll probably have to use either Object to Path or Stroke to Path, afterwards as well.  Not positive, but I think will be needed.
Title: Re: Can I Create A Dashed Line With The Lines and Spaces Set To A Certain Millimeter
Post by: Lazur on July 05, 2019, 12:09:26 AM
^-No.

Stroke to path=filled region= not a path that can be cut with one go. But a series of holes.

Whereas the attached example above along my first suggested solution would solve the problem most of the time.


Off-Topic: show
Not sure which forum etiquette would resolve the issue of me being gaslighted most of the time.
Hope you understand if I'm getting more and more annoyed. "Why bother?"
Title: Re: Can I Create A Dashed Line With The Lines and Spaces Set To A Certain Millimeter
Post by: brynn on July 05, 2019, 02:15:33 AM
No, I didn't mean to contradict or offend.  Just add extra info.

patrickonb just reported that it didn't cut the dashed line, only the solid line.  To cut the dashed line, there needs to be paths around the dashes.

So if you use PAP

 [ You are not allowed to view attachments ]

And you don't use
1 - Path menu > Object to path
2 - Path menu > Stroke to path

 [ You are not allowed to view attachments ]

Won't you just end up cutting the original, non-dashed path?

 [ You are not allowed to view attachments ]

Again?

There won't be any way to cut a series of dashes without picking up the cutting head, moving over and cutting again.  Well, there could be, if you draw it that way.  But I'm not clear that's what's wanted.
Title: Re: Can I Create A Dashed Line With The Lines and Spaces Set To A Certain Millimeter
Post by: Moini on July 05, 2019, 05:02:40 AM
Sorry, I forgot this part:

After making the dashes right, do Extensions > Modify Path > Convert to Dashes to turn the dashes into path segments.
Title: Re: Can I Create A Dashed Line With The Lines and Spaces Set To A Certain Millimeter
Post by: jimbalny on July 05, 2019, 02:18:32 PM
Wow, after using inkscape and getting frustrated with certain stroke settings that can't be unset (markers) I never knew about the XML editor until reading this post. Very handy, especially if you intend on using SVG code in a website.
Title: Re: Can I Create A Dashed Line With The Lines and Spaces Set To A Certain Millimeter
Post by: Lazur on July 05, 2019, 02:18:57 PM
Extensions > Modify Path > Convert to Dashes to turn the dashes into path segments.

Hah! you got me there, never used that extension before.
Maybe worth mentioning upon testing with the current stabile if the path is drawn as a B-spline (or as a spiro-path for that matter) the convert to dashes extension doesn't work as expected -need to convert object to path first.
Title: Re: Can I Create A Dashed Line With The Lines and Spaces Set To A Certain Millimeter
Post by: Moini on July 05, 2019, 02:54:10 PM
Lazur, you could make a bug report for this at https://gitlab.com/inkscape/extensions/issues/
Title: Re: Can I Create A Dashed Line With The Lines and Spaces Set To A Certain Millimeter
Post by: flamingolady on July 06, 2019, 08:44:07 PM
Well, I accidentally posted this in the wrong thread, so just for the sake of it, will copy it here...  better late than never, lol.

Not sure this is helpful, but I'll throw my 2 cents in.  I did a few tests (won't share them all), and the PAP worked, except that I didn't know how to do the code to tell it the size of the space between the dashes.... (I started with a 2.30 cm), did a few tests with doing a dash of 2.30, and space of 2.30. Would have been great except it didn't recognize the end space (I set the last dash to no stroke and no fill thinking it would create a gap).  Wondering if you could start with the 2.30 dash and then set the spacing size to 2.30 in code, then it'd be perfect, well the line would look perfect, so idea if the cutter would like it.