python中纹理如何分析_材质和纹理更改Python脚本

I am trying to make a script centered around changing the material via a drop-down menu and the texture via a slider. I am having some difficulty applying to a model. How can I change my script to fit this requirement?

import maya.cmds as mc

if mc.window("ram", exists =True):

mc.deleteUI(ram)

ram = mc.window("Material and Texture",t = "Material and Texture v0.9",

w=300, h=300)

mc.columnLayout(adj = True)

imagePath = mc.internalVar(upd = True)+"icons/scriptlogo.jpg"

mc.image(w=300,h=200,image = imagePath)

# A dropdown menu deisnged to change material/color of octopus (the colors

below are used as a test)

mc.optionMenu(label = "Material",)

mc.menuItem (label="Red")

mc.menuItem (label="Blue")

mc.menuItem (label="Yellow")

mc.menuItem (label="Green")

mc.menuItem (label="Orange")

mc.menuItem (label="Purple")

# A slider designed to alter the intensity of the octopus' texture

mc.intSliderGrp (label="Texture", min=0, max=10, field=True)

mc.showWindow(ram)

解决方案

Reading your question, I've no understanding of what you want to accomplish.

Here is an example on how to use menu items to set the color of lambert1, you can reproduce the syntax for the slider and the intensity of a texture :

import maya.cmds as mc

if mc.window("ram", exists =True):

mc.deleteUI(ram)

colors = {'Red':(1,0,0), 'Blue':(0,0,1), 'Green':(0,1,0)}

shader = 'lambert1'

ram = mc.window("Material and Texture",t = "Material and Texture v0.9", w=300, h=300)

mc.columnLayout(adj = True)

imagePath = mc.internalVar(upd = True)+"icons/scriptlogo.jpg"

mc.image(w=300,h=200,image = imagePath)

# A dropdown menu deisnged to change material/color of octopus (the colors below are used as a test)

menu = mc.optionMenu(label = "Material", cc=setColor)

mc.menuItem (label="Red")

mc.menuItem (label="Blue")

mc.menuItem (label="Yellow")

mc.menuItem (label="Green")

mc.menuItem (label="Orange")

mc.menuItem (label="Purple")

def setColor(*args):

colorName = mc.optionMenu(menu, q=1, v=1)

if colorName in colors.keys():

cmds.setAttr("{}.color".format(shader), *colors[colorName])

# A slider designed to alter the intensity of the octopus' texture

mc.intSliderGrp (label="Texture", min=0, max=10, field=True)

mc.showWindow(ram)

keep it mind it is really a basic example and you might want to read about querying value in maya ui, partial (or lambda), nested variables and dictionnaries

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值