Blender将对象长度导出到与混合文件位于同一目录中的CSV文件中



我需要一些帮助将CSV文件写入保存我的搅拌机文件的目录。我的搅拌机文件保存在C:/MyFile中,CSV需要写入同一文件夹。 C:/MyFile/file.text.如果我将搅拌机文件保存在其他地方,它也应该这样做。 我有的脚本运行良好,但它会导出到 C:/tmp/file.txt .提前谢谢。

# import the necessary modules we need
# in our case, blender's python API and python's os module
import bpy, os
# get the current selection
selection = bpy.context.selected_objects
# initialize a blank result variable
result = ""
# iterate through the selected objects
for sel in selection:
# get the current object's dimensions
dims = sel.dimensions
# write the selected object's name and dimensions to a string
result += "%s - %.03fm x %.03fm x %.03fmn" % (sel.name, dims.x, dims.y, dims.z)
# get path to render output (usually /tmp)
tempFolder = os.path.abspath (bpy.context.scene.render.filepath)
# make a filename
filename = os.path.join (tempFolder, "file.txt")
# open a file to write to
file = open(filename, "w")
# write the data to file
file.write(result)
# close the file
file.close()

我知道现在回答有点晚了,但如果它仍然对你有帮助,要做你想做的事,你只需要在"输出属性"菜单的"输出"选项卡中将"/tmp/"替换为".",不带引号。

最新更新