使用Python在特定文件夹中打开文件浏览器

时间:2013-04-09 12:15:36

标签: python explorer blender file-browser

我是法国人,如果我的英语不是很好,请原谅。 这是我的问题:我正在使用python制作一个与Blender一起使用的脚本,我需要导入一个.obj文件。我已经有了导入程序,但是我输入了整个文件路径。

看起来像那样:

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

相反,我想打开文件浏览器(例如 explorer.exe ),搜索.obj文件并为bpy.ops.import_scene.obj导入程序选择它。

你有什么想法吗?

谢谢,

ERO。

2 个答案:

答案 0 :(得分:0)

在我看来,这不是一种非常适合搅拌机的方式。

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

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

答案 1 :(得分:-1)

您可以使用Tkinter在python中选择一个文件: Choosing a file in Python with simple Dialog

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)
相关问题