搅拌机bpy.数据.材料.append(mat)应用mat twi

2024-09-29 22:32:28 发布

您现在位置:Python中文网/ 问答频道 /正文

我遇到了一件很奇怪的事。我正试着把一种新材料应用到一个物体上。我使用了一个条件,如果对象没有槽,则将材质附加到对象。下面是我的代码部分:

def Run():

curr_object= Import(obj_list, obj_extension)

#It is possible that the object has no slot material, and Blender is gonna fuss. Hence this security measure:

if curr_object.data.materials:
    curr_object.data.materials[0]= CreateMaterial(diffuse_path, normal_path)

else:

    curr_object.data.materials.append(CreateMaterial(diffuse_path, normal_path))


Export(outputFolderPath, obj_name)

我遇到了一个没有插槽的对象,因此使用了“else”函数。当我把这个东西重新放入搅拌机时,我意识到它有两次这种材料!我真的不明白是什么导致了这一切。有人能帮我吗?你知道吗

The two materials on the object

谢谢!你知道吗


Tags: thepath对象objdataobjectiselse

热门问题