Separate all faces (Blender-265a)

Hellow!
Sorry! I have bad English!:frowning:
Help me, please, separate all polygons


for p in me.polygons:
    p.select=True

don’t work


for v in me.vertices:
    v.select=True

don’t work

How select???


bmes = bmesh.from_edit_mesh(me)      
for f in bmes.faces:
    f.select = True
    bpy.ops.object.mode_set(mode='OBJECT', toggle=False)
    bpy.ops.object.mode_set(mode='EDIT', toggle=False)
    bpy.ops.mesh.separate(type='SELECTED')

don’t work:(

How for f in bmes.faces or for p in me.polygons separate all faces? All faces to individual objects?

You used the wrong operators, it doesn’t work like this in viewport either.

if bpy.context.object and bpy.context.object.type == 'MESH':
    bpy.ops.object.mode_set(mode='EDIT', toggle=False)
    bpy.ops.mesh.select_all(action='SELECT')
    bpy.ops.mesh.edge_split()
    bpy.ops.mesh.separate(type='LOOSE')

and what about separating only the selected faces?
I also need a help to figure out a way to process each face in order because the face index get assigned in a weird way.
I’m trying to assign a different texture to each face of a subdivided cube in a sequential row/column scheme.
anyone has already done this?

you don’t have to use custom functions for face center if you use bmesh module:
bm.faces[#].calc_center_median() or bm.faces[#].calc_center_bounds()

not sure about indices… maybe bm.faces.index_update() or bm.faces.sort() are useful for you. Also check out the “Sort Mesh Elements” operator.

Hi LanuHum, try this(run it from object mode):


import bpy

ob = bpy.context.active_object
bpy.ops.object.editmode_toggle()
bpy.ops.mesh.select_all(action = 'DESELECT')
bpy.ops.object.editmode_toggle()

mesh = ob.data

for i in range(len(mesh.polygons)-1):
    mesh.polygons[0].select = True 
    bpy.ops.object.editmode_toggle()
    bpy.ops.mesh.separate(type = 'SELECTED')
    bpy.ops.object.editmode_toggle()


Tested in 2.67 RC

can someone tell me why you need to seperate all faces ?

and there must be a edgesplit modifier to seperate all faces !

happy blendering

only selected faces was the request, but sure, you could do that by running the mark sharp operator and apply edge split modifier with split sharp option i guess. But doing the same with bmesh module for instance could be a nicer approach which wouldn’t require mode changes.

@CodeManX: Is “wouldn’t require mode change” important? Is that how we prevent generating scene.updates() while executing code?

Not sure what mode switching does, but i suppose it does update the object and the scene, just like operators.

And mode switching is slow, so bmesh has its clear advantages over standard API. But in recent builds, there is also update_from_editmesh() to flush selections and geometry without mode switching. However, it’s less powerful than bmesh module.