I have an object in my scene which is basically a point cloud, i.e. all vertices, no edges or faces. I'm trying to select a random fraction of this point cloud. Here is what the data looks like.
>>> bpy.data.objects[2].data.vertices[:]
[bpy.data.meshes['vertsMesh'].vertices[0], bpy.data.meshes['vertsMesh'].vertices[1], bpy.data.meshes['vertsMesh'].vertices[2], bpy.data.meshes['vertsMesh'].vertices[3], bpy.data.meshes['vertsMesh'].vertices[4], bpy.data.meshes['vertsMesh'].vertices[5], bpy.data.meshes['vertsMesh'].vertices[6], bpy.data.meshes['vertsMesh'].vertices[7], bpy.data.meshes['vertsMesh'].vertices[8], bpy.data.meshes['vertsMesh'].vertices[9], bpy.data.meshes['vertsMesh'].vertices[10], bpy.data.meshes['vertsMesh'].vertices[11], bpy.data.meshes['vertsMesh'].vertices[12], bpy.data.meshes['vertsMesh'].vertices[13], bpy.data.meshes['vertsMesh'].vertices[14], bpy.data.meshes['vertsMesh'].vertices[15], bpy.data.meshes['vertsMesh'].vertices[16], bpy.data.meshes['vertsMesh'].vertices[17], bpy.data.meshes['vertsMesh'].vertices[18], bpy.data.meshes['vertsMesh'].vertices[19], bpy.data.meshes['vertsMesh'].vertices[20], bpy.data.meshes['vertsMesh'].vertices[21], bpy.data.meshes['vertsMesh'].vertices[22], bpy.data.meshes['vertsMesh'].vertices[23], bpy.data.meshes['vertsMesh'].vertices[24], bpy.data.meshes['vertsMesh'].vertices[25], bpy.data.meshes['vertsMesh'].vertices[26], bpy.data.meshes['vertsMesh'].vertices[27], bpy.data.meshes['vertsMesh'].vertices[28], bpy.data.meshes['vertsMesh'].vertices[29], bpy.data.meshes['vertsMesh'].vertices[30], bpy.data.meshes['vertsMesh'].vertices[31]]
I'm thinking of a script that would resemble the following
count = int(vertices.length*fraction): # where fraction is a float generated by another function
for i in count:
rand = random number generated % vertices.length
delete vertices[rand]
I'm just not sure how this would be implemented in blender