I have a mesh with millions of densely packed vertices, and I what I want to do is be able to bisect them into separate objects. What I struggle with is selecting the vertices I want to be separated from the original mesh.
Trying with the solution given to this question gives me odd results, with either selected vertices not being within the given coordinates or selecting no vertices at all. Naturally, when I then separate the selected vertices I only separate the ones still selected from when I bisected the original object.
What am I missing here? Is there another way of selecting vertices that works better with my intentions or have I just slipped somewhere and can't see it myself?
This is the current structure of my code:
# centers the median point to center of mesh def CenterMedianPoint(): filepath = bpy.path.abspath("//space_view3d_move_origin.py") exec(compile(open(filepath).read(), filepath, 'exec')) # deselects all objects def DeselectObjects(): for obj in bpy.data.objects: obj.select = False # bisects object based on coordinates and direction def BisectObject(coX, coY, coZ, noX, noY, noZ): bpy.ops.mesh.bisect(plane_co=(coX, coY, coZ), plane_no=(noX, noY, noZ)) # get the dimensions of active object dimensionX, dimensionY, dimensionZ = bpy.context.active_object.dimensions # calculate dimensions and cell structure cutObjectDimensionX = dimensionX / 5 cutObjectDimensionY = dimensionY / 5 cutObjectDimensionZ = dimensionZ / 5 objectStartX = (dimensionX * (-1)) / 2 objectStartY = (dimensionY * (-1)) / 2 objectStartZ = (dimensionZ * (-1)) / 2 objectEndX = dimensionX / 2 objectEndY = dimensionY / 2 objectEndZ = dimensionZ / 2 cellCount = 1 parentCellCount = 1 # first cut iteration for i in range(0, 4): # selects object, enters EDIT mode and centers median point for easier coordinate calculation bpy.context.scene.objects.active = bpy.data.objects['objectToBisect'] bpy.ops.object.mode_set(mode = 'EDIT') bpy.ops.mesh.select_all(action='TOGGLE') CenterMedianPoint() # bisects objcet and selects bisected vertices BisectObject(0, (cutObjectDimensionZ-(cutObjectDimensionZ*i)), 0, 0, 1, 0) SelectVerticesInBound(bpy.data.objects['objectToBisect'], Vector((objectStartX, (cutObjectDimensionY-(cutObjectDimensionY*i)), objectStartZ)), Vector((objectEndX, objectEndY, objectEndZ))) # separates selected vertices into new object bpy.ops.mesh.separate(type='SELECTED') bpy.ops.object.mode_set(mode = 'OBJECT') DeselectObjects()
CenterMedianPoint script can be found here