Commits

Cedric Pinson committed e2a2893

raise a message if assigning an object to the current scene where the object does not exist, and remove debug log by default

Comments (0)

Files changed (1)

blenderExporter/osg/osgdata.py

         self.setArmatureInRestMode()
         if self.config.object_selected != None:
             o = bpy.data.objects[self.config.object_selected]
-            bpy.data.scenes.active.objects.active = o
-            bpy.data.scenes.active.objects.selected = [o]
+            try:
+                bpy.data.scenes.active.objects.active = o
+                bpy.data.scenes.active.objects.selected = [o]
+            except ValueError:
+                log("Error, problem happens when assigning object %s to scene %s" % (o.name, bpy.data.scenes.active.name))
+                raise
+                
         for obj in bpy.data.scenes.active.objects:
             if self.config.selected == "SELECTED_ONLY_WITH_CHILDREN":
                 if obj.isSelected():
             index = len(mapping_vertexes)
             merged_vertexes[i] = index
             mapping_vertexes.append([i])
-            debug("process vertex %s" % i)
+            if DEBUG: debug("process vertex %s" % i)
             vertex_indexes = vertex_dict[get_vertex_key(i)]
             for j in vertex_indexes:
                 if j <= i:
                     continue
                 if tagged_vertexes[j] is True: # avoid processing more than one time a vertex
                     continue
-                debug("   vertex %s is the same" % j)
+                if DEBUG: debug("   vertex %s is the same" % j)
                 merged_vertexes[j] = index
                 tagged_vertexes[j] = True
                 mapping_vertexes[index].append(j)