Glowforge making two passes over some single lines when only one pass specified

Looking at the SVG code:

Here’s an example of one of the paths:
d=“M58.8,14.1V6.2V14.1z”

D defines a path to be drawn
M is moveTo
V is LineTo
Z is close path

Break it down to:
d=
“M58.8,14.1
V6.2
V14.1
z”

So this path is saying something like, move to 58.8, then 14.1, Line to 6.2, then Line (back) to 14.1 and close, which is effectively a path doubling back on itself, I believe?

I just can’t tell ya how to fix it :slight_smile:

1 Like

Wow; this is super helpful stuff. Thanks, everybody. I think I may have caused my own problem by doing something dumb to the files while trying to solve a different problem (and doing it wrong) a couple of months ago. I’ll go back and find a version of the files that predates my clumsy “fix” effort and go from there…

@seth.r.johnson, what programs are you using to create the files? Illustrator? Inkscape? (Yeah, there is a doubling back on itself problem in a lot of the lines, but not all of them. It might be fixable in Illustrator using a centerline trace.)

1 Like

If I were fixing it I’d do the following:
EDIT: (in inkscape)

Select all

Set stroke to something wide, 1/8” or something

Set opacity to 50%

Any doubled paths will stand out like a sore thumb now

Depending on how many problem paths you have would set the next step… if you have a lot it might be simpler to redraw the shapes but if it is just a few:

Select a doubled path. Select all the nodes

Break apart all nodes. Now you’ll have a ton of individual line segments

Click on one doubled path. Delete. You should be left with one path now.

Continue, deleting the doubled paths.

Select all your single path line segments. Select all nodes that you want to be a single path and join them.

Should take care of you.

EDIT EDIT:
Previously - https://community.glowforge.com/search?context=topic&context_id=31999&q=%40evansd2%20opacity%20&skip_context=true

7 Likes

I’ve got access to both Illustrator and Inkscape. I’m finding I like both of these better than Corel Draw, which makes me want to cuss pretty regularly.

Okay, we’ve got a Centerline Trace tutorial for Illustrator here:

I think that will work if you have a lot of files to process. Since those are hairline, you probably won’t have to make adjustments to the line width.

If it was just one or two files, I would suggest just dragging and deleting the doubled lines individually, but they’re impossible to determine until you burn them and wind up overburning.

Try the Centerline Trace on one and see if it works. :slightly_smiling_face:

3 Likes

In Illustrator, you could run through use the direct select tool clicking on each path and deleting (or shift-click and delete multiple at once), but I can only imagine how tedious that would be for lots of files. But, I can’t think of any way to do programmatically (but that’s not my strong point either). You could open the file source and find the various instances of V (or H which is also used) and delete the second occurrences where the path doubles back.

I’d be concerned about it mimicking the paths exactly - trace is good but I don’t know that I would trust it for exactness.

Yeah, I was just thinking about that…it might be necessary to Expand/Combine and then Centerline trace.

Dammit, I’m really busy this morning, but I can probably run one quick test to see if it’s feasible…stand by… :smile:

Thanks so much!

I bet it would be pretty easy to do for 2-node closed paths using php or perl. (Or awk or sed) (or of you are desperate anything that has regex support like a text editor such as notepad++ or even JavaScript (ew))

d=“M58.8,14.1V6.2V14.1z”

Could be expressed as

Any path with an M, followed by 2 V’s and ending with a z

Then you just remove the Z from those instances.

Now I don’t know if all 2 node closed paths look like this or not, I’m just saying it shouldn’t be hard to do.

You could probably work out more complicated examples.

2 Likes

Okay, I tried a couple of things, and although they did work, I don’t really like the result because they slightly modify the lines involved. There is a curvature introduced into the lines, they are not perfectly horizontal and vertical after the trace, and although they will probably still appear to be completely vertical and horizontal when they are burned (it’s well within engineering accuracy and should not impact the fit or appearance) I don’t like introducing inaccuracies.

So scratch that one…sorry it didn’t work. :frowning:

2 Likes

OK so I poked at it some. I don’t know anything about SVG, but I think it would be easy to fix this.

d=“M58.8,14.1V6.2V14.1z”
OK so the key here is the V and H bits. You really want this to end up like this:

d=“M58.8,14.1V6.2”

So, if it were me, I would use php to parse each line, get the starting X and Y coordinates (58.8 and 14.1, respectively), then then remove the last one if it matched the start X or Y. It wouldn’t be hard to do, and would be worth the effort if you had several complicated files to fix.

I’ve got a bunch of other stuff to do or I’d take a whack at coding it up, but really this is a 20-line program, tops.

4 Likes

Here’s a quick primer on the H and V syntaxes for horizontal and vertical lines.

For your example of straight orthogonal lines with 2 nodes that double back on themselves, this is pretty simple to fix with a script. So simple that it makes me wonder if someone has already done this, I’d google around.

1 Like

I would either

A. Go back to the very originals and figure out what you did that caused it

B. Failing that, I would use the direct select tool in Illustrator, and just as you need a file, go in and shift-click the lines that need to be de-duped. It might take a few minutes for each file.

C. Figure out a script that will run through the SVG, but not sure how much time you’d need to put each one together to figure out the different circumstances. Some lines use H for the segments, some use V (both acceptable), etc.

Code theory is pretty easy for me, I just suck at writing it, so I’m pretty much relegated to just modifying existing code :slight_smile:

Rargh, you’re going to make me code it. It’s a fun small challenge. Question is whether @seth.r.johnson can run php somewhere. (I could do it in perl, but I’d be way slower). There’s no point to coding it up if he’s not able to /doesn’t need to run it.

So, Sethrjohnson? Do you need it and can you run it?

1 Like

Thank you! I think I can hack it out with some false starts.

1 Like

@evansd2: Thank you for the kind offer! I think I can figure this out by tracing back my steps to the original files and finding out where I introduced the problem. I’m pretty sure I know what I did, even. The insight from all of y’all was tremendously helpful: gave me nudge I needed to think through things more clearly. I’ll touch up this thread again if my efforts fail and I end up needing a script. :slight_smile:

3 Likes

Try put the file through https://jakearchibald.github.io/svgomg/

There is still some weird stuff going on though, so best if you can find originals and start again.

Thems fightin words! :yum:

1 Like