简体   繁体   English

我们如何使用python在Blender中更改文本颜色

[英]how can we change text color in blender with using of python

mat_red = bpy.data.materials.new("Text")
mat_red.diffuse_color = (0.85, 0.8, 1,1)
mesh = bpy.context.object.data
mesh.materials.append(mat_red)

not changing the color of text. 不更改文本的颜色。

While you are adding a material to the object, the material will only be used if no other material already exists on the object. 在向对象添加材质时,仅当对象上不存在其他材质时才使用该材质。 You can check the length of the material list to see if you want to append a new material or replace the existing material with your new one. 您可以检查物料清单的长度,以查看是否要添加新物料或将现有物料替换为新物料。

mat_red = bpy.data.materials.new("Text")
mat_red.diffuse_color = (0.85, 0.8, 1.1)
mesh = bpy.context.object.data

if len(mesh.materials) == 0:
    mesh.materials.append(mat_red)
else:
    mesh.materials[0] = mat_red

You could check the length first and adjust the existing material, then only create a new one when needed. 您可以先检查长度并调整现有材料,然后仅在需要时创建一个新材料。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM