我想用textScrollList做一个物料管理器。这是我的第一个代码,我用这个工具自学Python for Maya。目前,我的代码列出了场景中的材质,但它们是不可选择的。你知道吗
我遇到的问题是如何选择列出的材料。我认为我对“dcc”的定义是错误的。你知道吗
任何帮助在我的误解或不正确的做法将是可怕的!提前谢谢。你知道吗
这是我的密码:
import maya.cmds as cmds
def getSelectedMaterial(*arg):
selection = cmds.textScrollList(materialsList, query=True, si=True)
print selection
cmds.window(title='My Materials List', width=200)
cmds.columnLayout(adjustableColumn=True)
materialsList = cmds.ls(mat=True)
cmds.textScrollList('materials', append=materialsList, dcc="getSelectedMaterial()")
cmds.showWindow()
剧本注释中的解释!你知道吗
错误发生在这里:
您将
materialsList
定义为所有材质,但cmds.textScrollList()
需要您尝试查询的textScrollList
实例,您称之为“materials”。你知道吗将该行替换为以下行:
一般来说,对于GUI元素,我喜欢创建一个变量来捕获元素创建的结果,然后您可以稍后使用该变量进行查询或编辑。你知道吗
像这样:
希望有帮助
相关问题 更多 >
编程相关推荐