Cura icon indicating copy to clipboard operation
Cura copied to clipboard

[FR] Option to ignore 3MF file origin and arrange it like an STL when loading a file.

Open JohnEdwa opened this issue 3 years ago • 13 comments

3MF files have an origin, and Cura will place that origin to the front left corner of the bed. image This isn't helpful as basically no file will have been modeled so that the actual position of the model will match on your printer where you'd most likely want it, at the exact middle of the bed. This would not be such a huge problem, except for another 3MF feature: all bodies are automatically separated to individual parts. So, unlike an STL where the whole file is a solid chunk, if you press CTRL + R to arrange the models of a 3MF file, it will mess everything up: image (which I assume will be wonderful for print-in-place mechanisms, but that's a separate issue)

Anyway, I would like to request a Cura preference option that would force-load 3MF files the same way STL files are: place the actual middle of all the models at the exact centre of the bed, as is done with STL files: here's the same file, just saved & loaded as an STL.

image

JohnEdwa avatar Jun 20 '22 19:06 JohnEdwa

Hi, could you please provide the 3mf file that you used above, thanks.

smartavionics avatar Jun 20 '22 19:06 smartavionics

Boltcap.zip

JohnEdwa avatar Jun 20 '22 19:06 JohnEdwa

I can get it to load the group at the middle of the buildplate but haven't yet worked out how to centre the group. The problem seems to be that the models are separate so when I try and move them they all end up in the middle! More work required...

Screenshot_2022-06-20_21-21-15

smartavionics avatar Jun 20 '22 20:06 smartavionics

Hi, I'm making progress, could you please provide another example that contains multiple models but not all the same model. Also, could you please provide an example that uses, say, inches rather than mm? Thanks.

smartavionics avatar Jun 20 '22 21:06 smartavionics

testfiles.zip

Here you go. Also made one of them a "print in place" model where one body goes through a hole in another, so if you move both it messes them up.

JohnEdwa avatar Jun 20 '22 22:06 JohnEdwa

Looking good...

Screenshot_2022-06-20_23-24-15 Screenshot_2022-06-20_23-24-00 Screenshot_2022-06-20_23-23-23

The only oddity is that if you save the models on the buildplate as a .3mf file, each model is saved as if it is located at 0,0 and the XML contains transformations that specify the models' positions.

        <build>
                <item objectid="1" transform="1.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0 115.0 99.0 10.5" />
                <item objectid="2" transform="1.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0 165.0 99.0 10.5" />
                <item objectid="3" transform="1.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0 115.0 149.0 10.5" />
        </build>

But then when you load the file again it shifts the models further. So the upshot is that you can't round-trip 3mf files using cura with this new option enabled.

Anyway, it's getting late here so I'm done for the night.

smartavionics avatar Jun 20 '22 22:06 smartavionics

I have a solution, it can detect when a 3mf has been created by Cura and then it won't shift the models to the centre. So it will only shift models that are loaded from files created by other apps.

smartavionics avatar Jun 21 '22 17:06 smartavionics

This is in https://github.com/smartavionics/Cura/releases/tag/4.20.2

smartavionics avatar Jul 22 '22 07:07 smartavionics

I noticed that if the model has the origin somewhere in the middle of it while it is correctly placed in the X and Y, Z is kept at zero so it's pushed inside the build plate.

image

models.zip

[EDIT] ...and I'd like to specify that I'm not making buttplugs, it's a shifter knob. :P

JohnEdwa avatar Sep 08 '22 21:09 JohnEdwa

Hi, so I guess you would like it to translate the model vertically so that it sits on the buildplate rather than dangling through. I'll look into that next week.

smartavionics avatar Sep 08 '22 21:09 smartavionics

I've had a go at fixing this, not sure it's 100% right but it would be good if you could test this replacement for ThreeMFReader.py. which will be in the Cura installation tree somewhere.

You will need to rename from ThreeMFReader.txt to ThreeMFReader.py.

ThreeMFReader.txt

smartavionics avatar Sep 12 '22 20:09 smartavionics

That part works wonderfully, but I noticed that with "Automatically drop models to the built plate" enabled the model loads correctly but a split second later it is moved, usually downwards/underneath the bed. After that though if you lift the model, it works as expected.

JohnEdwa avatar Sep 12 '22 22:09 JohnEdwa

Hmm, well, I never use that automatic drop models thing so I didn't notice.

Here's a new version that ignores that option when the .3mf models are loaded at the centre of the build plate.

ThreeMFReader.txt

If this is OK now, I'll include it in the next release.

smartavionics avatar Sep 13 '22 06:09 smartavionics