2
$\begingroup$

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 ?

$\endgroup$
1
$\begingroup$

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

$\endgroup$
  • $\begingroup$ Isn't bmesh module able of re-creating the functionality? It will probably be slower than the operator, it should be possible to implement however. $\endgroup$ – CoDEmanX May 9 '14 at 9:57
  • $\begingroup$ Its possible to write in bmesh, and fairly fast since bmesh has connectivity data, but functionality doesn't exist out-of-the-box. $\endgroup$ – ideasman42 May 9 '14 at 10:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.