Python 搅拌机 - 如何为对象添加颜色?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4644650/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-18 16:44:07  来源:igfitidea点击:

blender - how do I add a color to an object?

pythonblender

提问by tekknolagi

When I try, nothing happens. I select a color and click the object and nothing.

当我尝试时,没有任何反应。我选择一种颜色并单击对象,然后什么也没有。

Maybe a python command?

也许是一个python命令?

采纳答案by 9000

  1. Select an object.
  2. In Button window (at bottom) select 'Shading' (a gray ball) and then 'Material buttons' (red ball)
  3. In 'Link and pipeline', press 'Add new'.
  4. Edit material color ('Col').
  1. 选择一个对象。
  2. 在按钮窗口(底部)中选择“阴影”(灰色球),然后选择“材料按钮”(红色球)
  3. 在“链接和管道”中,按“添加新”。
  4. 编辑材质颜色 ('Col')。

See it http://s3.amazonaws.com/twitpic/photos/large/222981727.png?AWSAccessKeyId=0ZRYP5X5F6FSMBCCSE82&Expires=1294658484&Signature=jDJpFXu7QI/7vGbW9BwBgL0trBU%3D

看到它 http://s3.amazonaws.com/twitpic/photos/large/222981727.png?AWSAccessKeyId=0ZRYP5X5F6FSMBCCSE82&Expires=1294658484&Signature=jDJpFXu7QI/7vGbW9BwBgL0trBU%3

回答by George Profenza

As @9000 mentioned, you might not have a material linked.

正如@9000 所提到的,您可能没有链接材料。

If you open a TextEditor window, you should be able to paste this script:

如果您打开 TextEditor 窗口,您应该能够粘贴此脚本:

from random import random
import Blender
from Blender import *

scn = Blender.Scene.GetCurrent()
ob  = scn.objects.active
m   = ob.getData(mesh=True)
if(len(m.materials) < 1):
    mat = Material.New('newMat')
    m.materials += [mat]
m.materials[0].rgbCol = [random(), random(), random()]


Blender.Redraw()

This should set random colours, if you have a material linked, otherwise creates a new material and links it.

这应该设置随机颜色,如果你有一个材料链接,否则创建一个新材料并链接它。

Note that you need Python installedon Windowsfor the console, and you need to start Blender from Terminalon OSX/Linuxto see the console. Also, the snippet works for Blender 2.49, not2.5x. You didn't mention which version of Blender you use.

请注意,您需要在Windows 上为控制台安装 Python,并且您需要在OSX/Linux上从终端启动 Blender才能看到控制台。此外,该代码段适用于 Blender 2.49而不是2.5x。您没有提到您使用的是哪个版本的 Blender。

HTH

HTH

回答by Anon

Use vertex paintin the options at the bottom:

在底部的选项中使用顶点绘制

click for an image

点击图片