Guest User

Untitled

a guest
Nov 16th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. # centers the median point to center of mesh
  2. def CenterMedianPoint():
  3. filepath = bpy.path.abspath("//space_view3d_move_origin.py")
  4. exec(compile(open(filepath).read(), filepath, 'exec'))
  5.  
  6. # deselects all objects
  7. def DeselectObjects():
  8. for obj in bpy.data.objects:
  9. obj.select = False
  10.  
  11. # bisects object based on coordinates and direction
  12. def BisectObject(coX, coY, coZ, noX, noY, noZ):
  13. bpy.ops.mesh.bisect(plane_co=(coX, coY, coZ), plane_no=(noX, noY, noZ))
  14.  
  15. # get the dimensions of active object
  16. dimensionX, dimensionY, dimensionZ = bpy.context.active_object.dimensions
  17.  
  18. # calculate dimensions and cell structure
  19. cutObjectDimensionX = dimensionX / 5
  20. cutObjectDimensionY = dimensionY / 5
  21. cutObjectDimensionZ = dimensionZ / 5
  22. objectStartX = (dimensionX * (-1)) / 2
  23. objectStartY = (dimensionY * (-1)) / 2
  24. objectStartZ = (dimensionZ * (-1)) / 2
  25. objectEndX = dimensionX / 2
  26. objectEndY = dimensionY / 2
  27. objectEndZ = dimensionZ / 2
  28.  
  29. cellCount = 1
  30. parentCellCount = 1
  31.  
  32. # first cut iteration
  33. for i in range(0, 4):
  34. # selects object, enters EDIT mode and centers median point for easier coordinate calculation
  35. bpy.context.scene.objects.active = bpy.data.objects['objectToBisect']
  36. bpy.ops.object.mode_set(mode = 'EDIT')
  37. bpy.ops.mesh.select_all(action='TOGGLE')
  38. CenterMedianPoint()
  39. # bisects objcet and selects bisected vertices
  40. BisectObject(0, (cutObjectDimensionZ-(cutObjectDimensionZ*i)), 0, 0, 1, 0)
  41. SelectVerticesInBound(bpy.data.objects['objectToBisect'], Vector((objectStartX, (cutObjectDimensionY-(cutObjectDimensionY*i)), objectStartZ)), Vector((objectEndX, objectEndY, objectEndZ)))
  42. # separates selected vertices into new object
  43. bpy.ops.mesh.separate(type='SELECTED')
  44. bpy.ops.object.mode_set(mode = 'OBJECT')
  45. DeselectObjects()
Add Comment
Please, Sign In to add comment