Import .stl directly into game

Using a python script that I attached to an object, I am able to import a mesh from a .stl file when the game starts using the following:

bpy.ops.import_mesh.stl(filepath="myFile.stl")

However, it doesn’t appear in my scene until I exit the game. As soon as I exit, it is there for me to edit, and do whatever, but I have to start the game again (which doesn’t help me). Is there any way to have it appear instantly while the game is running?

Don’t use bpy within bge(it is not avaible in standalone player, and most of its functions do not work with bge), and it is impossible create a mesh in runtime. You can edit mesh in realtime, but not add poligons(only modify existing), and replace the mesh of an object with other mesh(preloaded mesh), and apparently you cannot import mesh from files that are not. “blend”.

The bpy module is to use with addons/scripts for blender, but no bge.

Why you want to do that?

Better import into blender, save it to a blend and the bge will be happy ;).

@carlo:
Actually that is not true, Blender can add faces to meshes in realtime. You can prove that really easy by having an object in the scene with a modifier, as soon as you replace it’s mesh the modifier will be applied to the new mesh. That way you can for example subdivide or decimate meshes in realtime, unfortunatelly that works not with all modifiers since some will crash Blender.