From 3aa3623920641eadec02f7a514694cf406b92e11 Mon Sep 17 00:00:00 2001
From: Campbell Barton <ideasman42@gmail.com>
Date: Fri, 3 Jun 2011 05:03:17 +0000
Subject: [PATCH] dont export duplicate image URL's

---
 io_scene_x3d/export_x3d.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/io_scene_x3d/export_x3d.py b/io_scene_x3d/export_x3d.py
index 71df0e3da..f2cbc9f43 100644
--- a/io_scene_x3d/export_x3d.py
+++ b/io_scene_x3d/export_x3d.py
@@ -973,8 +973,11 @@ def export(file,
 
             images.append(os.path.basename(filepath_full))
             images.append(filepath_full)
+            
+            images = [f.replace('\\', '/') for f in images]
+            images = [f for i, f in enumerate(images) if f not in images[:i]]
 
-            fw(ident_step + "url='%s' " % ' '.join(['"%s"' % f.replace('\\', '/') for f in images]))
+            fw(ident_step + "url='%s' " % ' '.join(['"%s"' % f for f in images]))
             fw(ident_step + '/>\n')
 
     def writeBackground(ident, world):
@@ -1122,11 +1125,12 @@ def export(file,
         ident = writeFooter(ident)
 
     export_main()
-    file.close()
 
     # -------------------------------------------------------------------------
     # global cleanup
     # -------------------------------------------------------------------------
+    file.close()
+
     if use_h3d:
         bpy.data.materials.remove(gpu_shader_dummy_mat)
 
-- 
GitLab