I want to create a script that opens a blender file and splits the edges of all objects in it, perhaps ignoring those that are specified as smooth.
This is for a custom renderer that takes in blend files but interpolates ALL mesh normals from its vertices, which makes it difficult to have walls when they have a volume (i.e. their vertex normals don't match any of their faces).
It should be pretty straightforward, but blender's API comes off as strange to me, and I don't quite get the best way of doing things.
This is what I've got
import bpy
import sys
scene_file = sys.argv[sys.argv.index('--')+1]
bpy.ops.wm.open_mainfile(filepath=scene_file)
bpy.ops.object.select_all(action='DESELECT')
for i in bpy.data.objects:
i.select = True
bpy.ops.object.editmode_toggle()
bpy.ops.mesh.edge_split()
bpy.ops.object.editmode_toggle()
bpy.ops.wm.save_mainfile(filepath=scene_file[:-5]+'modded.blend')
I'm kind of trying to emulate the steps I'd take on the GUI, go through every object, get into edit mode, select all vertices/faces/edges, split edges, exit edit mode and continue. But it doesn't seem to do what I want (or anything in fact).
I've also seen the bmesh.ops.split_edges(bm, edges, verts, use_verts)
operator, but it requires mesh, edges and vertices, which I don't know how to retrieve from the object.
Also, I may want to make all normals consistent before splitting them just in case.