2 The meshLoader module contains a universal interface for loading 3D files.
3 Depending on the file extension the proper meshLoader is called to load the file.
5 __copyright__ = "Copyright (C) 2013 David Braam - Released under terms of the AGPLv3 License"
9 from Cura.util.meshLoaders import stl
10 from Cura.util.meshLoaders import obj
11 from Cura.util.meshLoaders import dae
12 from Cura.util.meshLoaders import amf
14 def loadSupportedExtensions():
15 """ return a list of supported file extensions for loading. """
16 return ['.stl', '.obj', '.dae', '.amf']
18 def saveSupportedExtensions():
19 """ return a list of supported file extensions for saving. """
20 return ['.amf', '.stl']
22 def loadMeshes(filename):
24 loadMeshes loads 1 or more printableObjects from a file.
25 STL files are a single printableObject with a single mesh, these are most common.
26 OBJ files usually contain a single mesh, but they can contain multiple meshes
27 AMF can contain whole scenes of objects with each object having multiple meshes.
28 DAE files are a mess, but they can contain scenes of objects as well as grouped meshes
30 ext = os.path.splitext(filename)[1].lower()
32 return stl.loadScene(filename)
34 return obj.loadScene(filename)
36 return dae.loadScene(filename)
38 return amf.loadScene(filename)
39 print 'Error: Unknown model extension: %s' % (ext)
42 def saveMeshes(filename, objects):
44 Save a list of objects into the file given by the filename. Use the filename extension to find out the file format.
46 ext = os.path.splitext(filename)[1].lower()
48 stl.saveScene(filename, objects)
51 amf.saveScene(filename, objects)
53 print 'Error: Unknown model extension: %s' % (ext)