# creating n random points on face of mesh

I'm trying to select 400 or so random points on the face of a mesh using a script (just on the face, not inside the volume) but I'm not sure how to do that.

I've tried looking into the following function:

bpy_extras.mesh_utils.face_random_points(num_points, tessfaces)


but I'm not sure how to use it in a script.

Currently, I've tried running it as such:

import bmesh

obj = bpy.data.objects[1] #Gets the object
me = obj.data
bm = bmesh.from_edit_mesh(me)
faces_select = [f for f in bm.faces if f.select]
bpy_extras.mesh_utils.face_random_points(400, faces_select)


but I get the following error:

Traceback (most recent call last):
File "<blender_console>", line 1, in <module>
File "C:\Program Files\Blender Foundation\Blender\2.75\scripts\modules\bpy_extras\mesh_utils.py", line 533, in face_random_points
verts = f.id_data.vertices
AttributeError: 'BMFace' object has no attribute 'id_data'


and I have no idea what that means. A simple script to select an object from bpy.data.objects and select 400 points from its faces would be really helpful.

as it is written bpy_extras.mesh_utils.face_random_points(num_points, tessfaces) takes tessfaces not faces and to get access to the you'll have to calculate first :

obj = bpy.context.object #Gets the object
me = obj.data
me.calc_tessface() # recalculate tessfaces
tessfaces_select = [f for f in me.tessfaces if f.select]
bpy_extras.mesh_utils.face_random_points(400, tessfaces_select)

• I think this works, but I'm not sure how to get the points to display in the scene. Sorry if this is a really simple question, I'm really new to blender scripting – paragbhtngr May 4 '16 at 4:10
• @paragbhtngr you want to see the points in the 3d_view or just have there coordinates ? you should know that these points are not vertices ( real points ) they are just calculated and you'll have to create them to be visible – Chebhou May 4 '16 at 7:47
• Yes, I want to create vertices from these points to be visible in the 3d view. How would I go about creating vertices from these points? – paragbhtngr May 4 '16 at 15:44
• Actually, never mind. I found the answer over here: blender.stackexchange.com/questions/23086/… – paragbhtngr May 4 '16 at 15:52