Loading

blender boolean test

  1. ### set object as Active
  2. #bpy.context.scene.objects.active = bpy.data.objects['Cube.'+objNumber]
  3.    
  4. ### add Boolean and set the target to Cube
  5. bpy.ops.object.modifier_add(type='BOOLEAN')
  6. bpy.context.object.modifiers["Boolean"].object = bpy.data.objects["Bool.Box"]
  7.  
  8. ### to_mesh - for some reason doesn't work    
  9. #bpy.context.object.to_mesh(scene = bpy.context.scene, apply_modifiers = True, settings = 'PREVIEW')
  10.  
  11. bpy.ops.object.modifier_apply(apply_as='DATA', modifier="Boolean")
  12.  
  13. vertexCount = len(bpy.context.object.data.vertices)
  14. print(vertexCount)
  15.  
  16. if vertexCount == 0:    
  17.     bpy.ops.object.delete(use_global=False)
  18.  
  19. if vertexCount > 0:
  20.     bpy.ops.object.group_link(group='Group')

Comments