# Objcet has no mesh data to be used for ray casting

When I try to do a ray_cast in object mode, I get an error “Object has no mesh data to be used for ray casting” I tried to fix it with following the steps:

bpy.context.scene.update()
context.active_object.data.update()
context.active_object.data.update(calc_edges=False)
context.active_object.update_tag(refresh={‘OBJECT’, ‘DATA’, ‘TIME’})


And even:

bpy.ops.object.mode_set(mode=‘EDIT’)
bpy.ops.object.mode_set(mode=‘OBJECT’)


Code Line 208

• I think this is a currently bug or oversight. Fails with same error in console C.object.raycast(v, d) The template operator raycast exhibits this behaviour too. (once fixed for missing dupli in 2.8) Re your script, not sure about the logic re mw.inverted() * f.normal. Suggest converting to global space, and then to local space of the object you are raycasting from. global normal – batFINGER Dec 23 '18 at 11:27
• Thank you very much. Regarding logic, you are right, thanks! – Влад Киндюшов Dec 23 '18 at 12:42
• unfortunately at the moment blender2.8 gives the same behaviour for the closest_point_on_mesh method. – richard Dec 31 '18 at 12:29