3
$\begingroup$

I was wondering if it is possible to activate the 'Split' tool in python. I'd like to make a script that loops through the selected objects polygons and splits them, creating an object with all its faces separated from each other. Is this possible? If not, is there a work-around? If none of this is possible, then could one make a script where it selects a face of an object, and selects the next face when the user presses the Y key (the hotkey for 'Split')? Thanks for any help in advance.

$\endgroup$
3
$\begingroup$

This can be done using the bmesh api.
The operator you are looking for is bmesh.ops.split.

However, the functionality you want to create is already in blender, with CtrlE> Edge split, or bpy.ops.mesh.edge_split

Note that you could also create and apply an Edge split modifier, however it's probably easier to use the edge_split operator.


As for selecting the "next face", you can select a face by setting its select value to True:

bpy.context.object > data > polygons > select

E.g. bpy.context.object.data.polygons[0].select = True will select the face with an index of 0 in the active object.

Note that you have to be in object mode for this to work:

The mesh data is accessed in object mode and intended for compact storage, for more flexible mesh editing from python see bmesh.

You can set the mode with the mode_set operator, e.g. bpy.ops.object.mode_set(mode='OBJECT')

How you define the "next face" is up to you, as AFAIK there is no absolute definition of which face should be the "next" one.

$\endgroup$

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.