Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # 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()
Add Comment
Please, Sign In to add comment