Detecting Exterior Perimeters via Gcode

Anyone have any ideas on how to detect exterior perimeters only by looking at gcode? Feed rate alone can't be used due to layer cooling features within the slicer. Keep in mind that multiple objects may be printed. I would could holes in the middle of the print as exterior as well, or they can be classified some other way.

Preferably this could be done per layer, and could be done pretty efficiently. Ideally each gcode could be tagged somehow as being an exterior.

Thanks!

You can switch on the "Verbose G-code" option in Slic3r PE. It adds a comment at the end of every line.
https://manual.slic3r.org/expert-mode/print-settings

G1 X117.167 Y97.885 E1.91373 ; wipe and retract
G1 X120.279 Y97.885 E0.80504 ; wipe and retract
G1 E0.70504 F2700.00000 ; retract
G92 E0 ; reset extrusion distance
G1 X118.849 Y99.433 F9000.000 ; move to first perimeter point
G1 X96.997 Y94.535 ; move to first perimeter point
G1 X97.201 Y94.376 ; move to first perimeter point
G1 E2.00000 F2700.00000 ; unretract
G1 F3000
G1 X97.556 Y94.205 E2.00518 ; perimeter
G1 X98.146 Y93.990 E2.01342 ; perimeter
G1 X98.754 Y93.835 E2.02167 ; perimeter
G1 X99.316 Y93.750 E2.02913 ; perimeter
1 Like

Cura out-of-the-box tags sections of gcode with comments. These reasonably repeat for the average print job without supports.

;TYPE:WALL-INNER
;TYPE:WALL-OUTER
;TYPE:SKIN

Is this what you had in mind? Or are you asking "what is the min-x/max-x, min-y/max-y for the entire job?"

1 Like

Interesting, I will take a look at that, thanks!

That is definitely another possibility. I was thinking more along the lines of an algorithm that could detect the outer edges given the extrusion start and end points, but this is another viable option. I'm guessing simplify has something similar.

But also remember that foosel detects the bounding box for her out-of-bounds check.

I'm not looking for the bounding box, but rather I want to know which gcodes are extruding on the exterior perimeters so I can avoid causing movements during or right before any exterior perimeters are printed. Basically I'd like to create something that says, "this gcode will put plastic down that will be visible once the print is removed and cleaned up." I've been thinking about the math involved, and it's beyond me.

Slic3r's verbose comments only show 'perimeters' and do not specify if they are external or not, but that info is better than nothing.

So, I'm working on your suggestions, and will let you know how it works. It turns out Slic3r PE and PrusaSlicer doesn't differentiate between exterior/interior/small perimeters at all unfortunately, nor does it add any info about print speed slowdown triggered by cooling settings or any layer time information that I could see. I will investigate the post processor to see if there's anything that can be added.

However, it gives some other interesting info, like when a movement is towards a perimeter or infill (really nice for me). I will investigate more about cura and simplify and will let you know what I find.

Slic3r PE also has an option to force the speed of the external perimeters (the "visible ones", as specified in the tool-tip). You can then find the matching Fxxx codes in your G-code (your chosen speed in mm/min).

For a coding approach, look for "concave hull" and "alpha shape".
http://docs.pointclouds.org/trunk/group__surface.html
https://www.researchgate.net/post/Does_anyone_know_any_existing_algorithm_to_find_the_external_and_internal_boundary_points_of_a_point_cloud

1 Like

The math based approaches you have listed were what I was originally looking for, thanks for posting. I might have to roll up my sleeves and try that out.

FYI, the comment based stuff seems to be working. That pretty much takes care of Simplify 3d and cura. I might add a feature request for prusa slicer for them to be more specific about the verbose comments, or better yet, just add comment sections like cura and simplify do, which would speed processing and waste less space. I don't have high hopes about that.

1 Like

Last update for this thread: I ran a test of the comment based feature detection, and it has really improved quality when printing some particularly tricky stuff. It requires no settings, and works as long as the expected comments appear. I'm really happy with it so far! Now that my gcode processor is really performing well, I may look into one of the algorithms above to deal with other slicers, or gcode without comments. For now I am pretty satisfied since I've seen an obvious increase in quality on prints that I have really been having trouble on. Specifically when using very small layer heights (0.05-0.1mm) with very low layer times.

I also discovered something else about printing that might require a new thread: There is WAY more oozing when printing small layers at a low layer height. Like 5x or more. My theory is that when the extrusion speed is low the plastic gets to a higher temp inside the nozzle, making it less viscus, but I'm not 100% certain. I watched an entire print (every snapshot) and the difference when printing at low speeds was incredibly obvious. Maybe we need a new slicer setting to reduce temps when the print speed is reduced? Manually dropping the temps by about 15C on the small layers did make a pretty big difference, but the oozing was still worse on the small layers. I suppose it also could have something to do with nozzle pressure. Anyway, I found that interesting too.

We tend to think that plastic is forgiving but it's about as fickle as it can be. I have a theory that static electricity is also a forgotten variable in all this: extrusion generates static electricity. Since like charges repel there's a natural tendency for the nozzle pressure to be higher than you would otherwise expect based upon other factors. I would suggest that a well-grounded nozzle would ooze less.