Ghostkeeper / Blender3mfFormat

Blender add-on to import/export 3MF files
GNU General Public License v2.0
202 stars 25 forks source link

Fix mesh not loading for 3mf files generated by Bambu Studio #70

Open YoakeNoTenshi opened 4 months ago

YoakeNoTenshi commented 4 months ago

This is to fix an issue with some 3mf files generated by Bambu Studio as described in https://github.com/Ghostkeeper/Blender3mfFormat/issues/69

Basically the 3dmodel.model file contains references to components defined in other model files. So when it tries to build the build/items the script can't find the sub components in resource_objects and logs the error Build item with unknown resource ID. Sub components are loaded in resource_objects later on but never converted to actual Blender objects.

This fix loads all the models in the 3mf file in resource_objects and then creates all the Blender objects. This assumes all the object IDs are unique and I don't know if that's actually the case.

This was tested with the 3mf file here: https://makerworld.com/en/models/20200#profileId-20736

Before the fix: image

After the fix: image

Ghostkeeper commented 3 months ago

The automated code style check is complaining that there's whitespace characters on an empty line at line 146 of import_3mf.py. I'll fix that up for you if/when merging, it's a really minor thing.