import maya.cmds as cmds
import maya.mel as mel
nodes = cmds.ls(selection=True, dag=True)
## Open the panel, doesn't re-open if already up and sets focus
cmds.HypershadeWindow()
## Get the name of the hsPanel
hsPanel = cmds.getPanel(withFocus=True)
## Clear the graph
cmds.hyperShade(resetGraph=True, dependGraphArea=True)
for node in nodes:
if len(nodes) > 0:
## Select a node
cmds.select(node, r=1)
## List the materials assigned to the object
cmds.hyperShade(shaderNetworksSelectMaterialNodes=1)
## Create an array of the materials
materialSelection = cmds.ls(sl=1)
## Loop over the materials and graph them
for material in materialSelection:
# cmds.select(material, r=1)
try:
cmds.hyperGraph(hsPanel, edit=True, addDependNode=material)
except:
mel.eval("hyperShadePanelGraphCommand(\"%s\", \"addSelected\")" % hsPanel)
else:
cmds.warning("Please select an object")
从你的代码中我可以确定的是,你在寻找select对象的材质。在
因此,这将循环覆盖对象并将其着色器添加到图形中。最初,它将在开始添加之前清除图形,您可以通过简单地清除标志
resetGraph=True, dependGraphArea=True
来删除该功能。在我不喜欢使用mel eval语句hyperShadePanelGraphCommand()
,但是我找不到python的替代品。很高兴有人能纠正这一点!相关问题 更多 >
编程相关推荐