0

I'm a french guy, so excuse me if my English is not very good. Here is my problem : I'm using python to make a script that works with Blender, and I need to import an .obj file. I already have the importer, but I enter the entire filepath.

It's look like that :

bpy.ops.import_scene.obj(filepath='C:/Users/MarcPro/Desktop/testauto/03-Reconstruction/Data/Tile/Tile.obj', axis_forward='Y', axis_up='Z')

Instead, I would like to open a file browser (for example explorer.exe), go search for the .obj file and select it for bpy.ops.import_scene.obj importer.

Do you have any idea please ?

Thanks,

Ero.

4

2 回答 2

0

在我看来,这不是一个非常适合 Blender 的方法。

我认为您想要做的是使用内置的 Blender 文件选择对话框来选择文件。

我不确定,但这可能适用于bpy.types.WindowManager.fileselect_add.

于 2013-04-09T12:22:38.430 回答
-2

您可以使用 Tkinter 在 python 中 选择文件:使用简单对话框在 Python 中选择文件

from Tkinter import Tk
from tkFileDialog import askopenfilename

Tk().withdraw() # we don't want a full GUI, so keep the root window from appearing
filename = askopenfilename() # show an "Open" dialog box and return the path to the selected file
print(filename)
于 2013-04-09T12:18:57.833 回答