Bounding box or first move wrong when using "User origin" (LB 1.7.04, Snapmaker 2.0)

I just had a nasty surprise with Lightburn in conjunction with my Snapmaker 2.0. I created a job that deliberately had nothing at the work origin, but the first object to be lasered was offset. This was to align the job with the corner of the workpiece. I created the GCode as usual, loaded it into my Snapmaker 2.0, started the setup (focus, work origin), and after that did a “run boundary”. This traced the target area on the workpiece nice and correctly. Confident, I started the actual laser process, and was unhappily surprised by the first lines being lasered at the wrong place! So here’s a bit of post-mortem:

The job setup in Lightburn (ignore the white box - text is “confidential” :slight_smile: ):

From the laser job that messed up things here are the relevant GCode parts:

;Header Start
;header_type: laser
;file_total_lines:16875
;max_x(mm): 149.84
;max_y(mm): 207.15
;max_z(mm): 0
;min_x(mm): 58.11
;min_y(mm): 49.57
;min_z(mm): 0
;thumbnail: 
[...]
;Header End
; LightBurn 1.7.04
; SnapMaker device profile, user origin
; Bounds: X58.11 Y49.57 to X149.84 Y207.15
G21
G90
G0 X0 Y0 F0
G91
; Offset @ 1000 mm/min, 100% power
M107
M05
G0 X6.793 Y1.462 F0
; Layer C00
G1 X0.068 Y0.185F1000 I S255
[...]

Noteworthy: Correct bounding box in header; G91 → relative positioning; First move to X6,793 Y1.462 → Close to the starting point and wrong!

Reason: Selected “User Orign” as “Start From:” value. I think this is the default setting, but I may be wrong here.

Problem is: Lightburn decides that the “User Origin” is the corner of the lowest and leftmost object:

So, I changed to “Absolute Coords”. Resulting GCode:

;Header Start
;header_type: laser
;file_total_lines:16869
;max_x(mm): 149.84
;max_y(mm): 207.15
;max_z(mm): 0
;min_x(mm): 58.11
;min_y(mm): 49.57
;min_z(mm): 0
;thumbnail: 
[...]
;Header End
; LightBurn 1.7.04
; SnapMaker device profile, absolute coords
; Bounds: X58.11 Y49.57 to X149.84 Y207.15
G21
G90
; Offset @ 1000 mm/min, 100% power
M107
M05
G0 X64.906 Y51.036 F0
G0 Z0
; Layer C00
G1 X64.974 Y51.22F1000 I S255
[...]

Noteworthy: Same bounding box in header; G90 → Absolute positioning; First move to X64.906 Y51.036 → This is correct!

So, just out of curiosity I tried the third option, “Current Position” (which does not make sense in my case as I do not control the Snapmaker directly via Lightburn, i.e. it is not connected to Lightburn in any way) - and also for current position it seems that the lowest leftmost object defines “Current position” - GCode:

;Header Start
;header_type: laser
;file_total_lines:16874
;max_x(mm): 91.73
;max_y(mm): 157.58
;max_z(mm): 0
;min_x(mm): 0
;min_y(mm): 0
;min_z(mm): 0
;thumbnail: 
[...]
;Header End
; LightBurn 1.7.04
; SnapMaker device profile, current position
; Bounds: X0 Y0 to X91.73 Y157.58
G21
G91
; Offset @ 1000 mm/min, 100% power
M107
M05
G0 X6.793 Y1.462 F0
; Layer C00
G1 X0.068 Y0.185F1000 I S255
[...]

Noteworthy: Different bounding box (The reduced one - this would have warned me when doing “run boundary” as the area would have been wrong); G91 → Relative positioning; First move to X6.793 Y1.462 - which is correct in the sense of the file, but wrong for my aim.

So long story short: The “User origin” output of Lightburn is buggy - either you need to correct the bounding box, or the first move.

Are you thinking this means current position in Lightburn? In Absolute Coords or User Origin, Lightburn creates the code from a known location. with Current Position, neither Lightburn nor anyone else except the laser knows where the laser head is located. Lightburn issues no motion commands prior to starting the burn. So being connected means nothing because you told it to start burning no matter where it is located.

Not exactly, you told it by using those little round buttons under the Start From selection. Those positions refer to the bounding box of the selection.

I have added the links below to help you understand how the various coordinate system work (very well in my experience).

Here is an excellent video by @thelmuth worth watching about 5 times…

Thanks for pointing me to the explanations, and I’m the first to admit that part of my problem is my ignorance :slight_smile:
Still, in one point I’d insist on my point: The bounding box in the GCode header should match what’s actually happening in the GCode - so IMHO it is a bug that the bounding box comment is not where the laser operation actually takes place.
This may be a pure Snapmaker issue - I’ve honestly no idea if the bounding box comment lines are in any way universal and other machines evaluate them, or if only Snapmaker uses them.

Some controllers do not use the Lightburn FRAME command because Frame is built into the controller. I do not know if this is true for a Marlin controller. However, the bounding comment should match what Lightburn uses when it does a Frame. I would be very surprised if any controller uses a free text comment line for an operation. There is no standard for comments except they start with a semicolon and have limited length.

Frame is just a short Lightburn program sent to the controller, like a macro. Assuming you are not messing with the coordinate systems, Frame should go where the screen says it will go. Have you played with the Circular Frame button?