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 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 myobj.primitive_plane_add() bpy.ops.object.editmode_toggle() myobj.subdivide(number_cuts=3,smoothness=1) myobj.select_all(action='TOGGLE') 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.