Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
46 lines (41 sloc) 1.5 KB
# Add Blender scripts to path so that import/export functions are available.
import sys
import Blender
import import_obj
import minilight_export
import off_import
import os
import sys
HELP = """Import a OBJ/OFF file into Blender and exports it as a MiniLight file.
filename=<filename> blender -P
if __name__ == '__main__':
filename = os.getenv('filename')
if filename is None:
print HELP
scene = Blender.Scene.GetCurrent()
# Blender's default view has a cube. This script cannot be run in batch
# (-b) mode because Blender cannot join objects there.
print 'Removing default cube...'
scene.objects.unlink((o for o in scene.objects if == 'Cube').next())
print 'Importing model...'
if filename.endswith('.obj'):
# Import model from OBJ file.
elif filename.endswith('.off'):
# Import model from OFF file.
# Join objects.
print 'Joining objects...'
other_objects = [scene.objects[i] for i in range(1, len(scene.objects))]
for o in other_objects:
scene.objects.unlink(o) = scene.objects[0]
# Export to MiniLight.
print 'Exporting model...'
minilight_export.write(filename + '.ml.txt')