【发布时间】:2019-05-18 12:04:53
【问题描述】:
这是我的计划。首先创建一个关节并打开您的节点编辑器。创建关节后,运行脚本后将其命名为“A_Joint”并点击“加载关节”,然后在点击测试时点击“测试”,您应该会创建一个名为“A_Joint_firstGuy”的节点
此脚本的目标是根据您加载到文本字段中的任何内容的名称创建一个节点。它将获取所选对象的名称并将其添加到节点名称的前面
至少这是应该发生的事情,但事实上我缺乏解决这个问题的知识,而且迄今为止每次谷歌搜索都没有结果。脚本在下面供任何愿意尝试的人使用,感谢您的宝贵时间,我希望收到您的回复:
https://drive.google.com/file/d/1NvL0MZCDJcKAnVu6voVNYbaW0HurZ6Rh/view?usp=sharing
或者在这里,以 SO 格式:
import maya.cmds as cmds
if cmds.window(window, exists =True):
cmds.deleteUI(window)
window = cmds.window(title = "DS Selection Loader Demo", widthHeight=(300, 200) )
cmds.columnLayout(adjustableColumn=True)
def sld_loadHelperJoint():
sel = cmds.ls(selection=True)
selString = " ".join(sel)
add = cmds.textField('sld_surfaceTextHJ', edit=True, text=selString)
#def sld_loadParentJoint():
# sel = cmds.ls(selection=True)
# selString = " ".join(sel)
# add = cmds.textField('sld_surfaceTextPJ', edit=True, text=selString)
def createNode():
testNode = cmds.createNode( 'transform', selString = "sld_surfaceTextHJ", name = '_firstGuy' )
cmds.columnLayout(adjustableColumn=True)
sld_textFld = cmds.textField('sld_surfaceTextHJ', width =240)
cmds.button( label='Load Helper Joint', command = "sld_loadHelperJoint()")
cmds.setParent('..')
#cmds.columnLayout(adjustableColumn=True)
#name = cmds.textField('sld_surfaceTextPJ', width =240)
#cmds.button( label="Load Parent Joint", command = "sld_loadParentJoint()")
#cmds.setParent('..')
testNode = cmds.createNode( 'transform', name = textField +'_firstGuy' )
# you must first create "def" group for the attributes you
# want to be created via button, "testNode" is our example
# Connect the translation of two nodes together
#cmds.connectAttr( 'firstGuy.t', 'secondGuy.translate' )
# Connect the rotation of one node to the override colour
# of a second node.
#cmds.connectAttr( 'firstGuy.rotate', 'secondGuy.overrideColor' )
cmds.showWindow (window)
【问题讨论】:
标签: python textfield maya autodesk