Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2011-01-23 11:57:54 +0300
committerCampbell Barton <ideasman42@gmail.com>2011-01-23 11:57:54 +0300
commitd326b12f406121fac12b297be76a04b1ab5353b4 (patch)
tree8e899deda74fd4ab1482353418c302658db7671f /io_scene_obj
parent6dbb21f4c0ca5927b870ae066d5148d0aa2efd81 (diff)
write materials in a alphabetical order
Diffstat (limited to 'io_scene_obj')
-rw-r--r--io_scene_obj/export_obj.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/io_scene_obj/export_obj.py b/io_scene_obj/export_obj.py
index 2fe4a804..9bfb196a 100644
--- a/io_scene_obj/export_obj.py
+++ b/io_scene_obj/export_obj.py
@@ -62,8 +62,13 @@ def write_mtl(scene, filepath, copy_images, mtl_dict):
file = open(filepath, "w", encoding="utf8", newline="\n")
file.write('# Blender MTL File: %r\n' % os.path.basename(bpy.data.filepath))
file.write('# Material Count: %i\n' % len(mtl_dict))
+
+ mtl_dict_values = list(mtl_dict.values())
+ mtl_dict_values.sort(key=lambda m: m[0])
+
# Write material/image combinations we have used.
- for key, (mtl_mat_name, mat, img) in mtl_dict.items():
+ # Using mtl_dict.values() directly gives un-pradictable order.
+ for mtl_mat_name, mat, img in mtl_dict_values:
# Get the Blender data for the material and the image.
# Having an image named None will make a bug, dont do it :)