I am trying to split a mesh randomly into N pieces by assigning user defined percentage (out of 100%) of faces to each nth-piece. As shown below. In parallel, I would also like to have Random Seed that track history of these randomly split meshes
. This is what I am trying to do

I can select only 1 face at a time through the script but not multiple faces at a time getting following error
. enter image description here

This is my so far a try to accomplish this task: # Divide Mesh into n Pieces with m% # for example: if n=3, User ask to input percentages for Piece 1,2 and 3 # The percent should be 100% and pieces contain random faces in the mesh # The combination of pieces selection should also be random seeded.

import bpy
import bmesh

myobj = bpy.ops.mesh

me = bpy.context.object
bm = bmesh.from_edit_mesh(me.data)

for i in range(len(bm.faces)): #in my test case 16 faces in total
    i = i + 2
    bm.faces[i].select=True #select every second face-Just checking if different pattern of selection works.

bmesh.update_edit_mesh(me.data, True)

Once it select random faces in a mesh split them and make N pieces.

  • $\begingroup$ Not answer (what is the question exactly ?!) , but there is blender.org/api/blender_python_api_2_63_7/… $\endgroup$ – Calvin1602 Oct 21 '16 at 15:31
  • $\begingroup$ Random selection will not give me the exact number of percentage of selection. How can I divide a mesh into N pieces with percent factor assign to each piece. I am a beginner in Python scripting. $\endgroup$ – mGm Oct 21 '16 at 15:51

Your Answer

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

Browse other questions tagged or ask your own question.