I’m trying to edit the LBRN2 files with a Python script by parsing the XML.
My goal is to apply an X and Y translation and then a rotation, all using the top right corner as a reference point. My files are coming in as DXF which I’m importing (with group on import) and then saving as LBRN2. I’m using LightBurn 0.9.24
So far I’ve found that I can change the XForm values on the group to apply rotations and translations, even skew, but I’m getting a bit stuck as it’s also flipping my files and my results are not yet predictable and consistent.
Can you please explain the 6 values in the XForm tag for me, by any chance? I think I can get the rest of the way with a little explanation on those.
Here’s what I’ve got so far:
Import DXF and then save as LBRN2. Here’s a snippet of how the XML looks:
</CutSetting>
< Shape Type="Group" CutIndex="0">
< XForm>-1 0 0 -1 320 0</XForm>
< Children>
< Shape Type="Path" CutIndex="4" VertID="20" PrimID="12">
< XForm>1 0 0 1 0 0</XForm>
< VertList>V303.50201 -112.423c0x1c1x1V303.46301 -112.423c0x1c1x1V303.35999
I can change values in the area to successfully apply speed, power, and priority based on the index.
I can set the XForm values based on this formula:
{cos_theta} {sin_theta} {sin_theta} {-cos_theta} {x} {y}
That does the translation to X and Y with a rotation of theta (in radians) but it also flips the job through the vertical axis.
I think the XForm might be in reference to the top left corner?
I can see that the XForm values get applied in a hierarchy to all objects below them. It looks like there is a reference frame that the VertList points are in reference to, which is based on how the DXF file is set up. And then the reference frames get all the XForm translations above them, with the values 1 0 0 1 0 0 causing no translation.
This post was helpful for the vector encoding, but I’m after some more info on the XForm values.
Thanks for the info