引用变量文件名

时间:2014-08-28 17:57:00

标签: python variables filenames blender

您好我正在尝试在blender中编写一个涉及以下命令的python脚本:

bpy.ops.wm.save_as_mainfile(filepath = r"C:\Users\mrryan\Desktop\ 'customer_id' + orangecube.blend)

这个想法是脚本使用变量和标准文件名保存文件' 例如;

创建3141orangecube.blend

我已将customer_id定义为:

customer_id = "3141"

如果没有这个变量,我的脚本运行正常,但怀疑语法错误。

请帮忙。

2 个答案:

答案 0 :(得分:0)

This is how we concatenate strings:

foo = '42'
print 'bar' + foo + 'baz'

答案 1 :(得分:0)

试试这个:

filepath = os.path.join(r"C:\Users\mrryan\Desktop", customer_id + "orangecube.blend")
bpy.ops.wm.save_as_mainfile(filepath = filepath)

不要忘记文件顶部的import os