# Script to separate an object's mesh without using bpy.ops

I've seen several posts suggesting that it's better to write functions that manipulate bpy.data directly, instead of using the bpy.ops operators. I can understand the argument about how operators such as bpy.ops.mesh.separate() are meant for the user interface, requiring context such as the active object or the mode (object vs. edit), usually given by the user.

But the operators are convenient because they embody so much of Blender's functionality already, and I don't want to have to re-code that from scratch... So where I can find this functionality in Blender's API, apart from the bpy.ops operators ? Is it in bmesh ?

Here's a specific example : if I want to code the equivalent of "separate", I need (among other things) to identify, in the set of vertices that I want to separate, which ones are on the 'borders', so I can duplicate them. This would probably involve navigating around the mesh data, iterating over each vertex's neighbors, and checking whether they're inside my set. Not trivial for a newbie. So is there a function for this ?

No, currently the only method for splitting objects uses bpy.ops, there aren't always API equivalents for each blender operator.