27. Exporting our model data from Blender

Questions and discussion for this lecture live here. Fire away by hitting Reply below :fire:

Hi Sean, I have noticed that it’s far too easy to forget to merge nodes and apply transformations before exporting our model. In the exporting script after imports, we can just add the following lines so that we don’t have to remember to perform those operations manually.

previous_mode = bpy.context.object.mode
if bpy.context.object.mode != 'EDIT':
    bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.select_all(action = 'SELECT')
bpy.ops.mesh.remove_doubles()
bpy.ops.mesh.select_all(action='DESELECT')
if bpy.context.mode != 'OBJECT':
    bpy.ops.object.mode_set(mode='OBJECT')
bpy.ops.object.transform_apply(location = True, rotation = True, scale = True)
bpy.ops.object.mode_set(mode=previous_mode)

Nice work @Oliviero :+1:

Seán

1 Like