Reputation: 645
I want to import an object from obj file that was created in blender into blender game engine bge from a python script. In the docs, there is no import function listed, but I can do it from UI. Does anybody know what function is needed to import a .obj into blender 2.79?
Import via UI works perfectly, but it must be randomized and automatized in a script
export:
bpy.ops.export_scene.obj(filepath="myPath/test.obj",
filter_glob="*.obj",
use_selection=True)
possible import:
bge.xxx.import("myPath/test.obj") ??
Upvotes: 0
Views: 3790
Reputation: 645
Well, I found the answer. I could not import bge to blender rendering, but vice versa it works. So if you switch to Blender Game, you cannot only import bge.logic, but also bpy, which allows you to import meshes with all textures etc. with this command:
bpy.ops.import_scene.obj(filepath="myPath/myFile.obj")
access is possible using scene.objects.
I could delete the question but I will leave it open in case somebody else encounters the same problem.
Upvotes: 1