我想使用文本字段的输出作为新创建的blenshape 的名称。但是,当我按下按钮创建形状时,它只考虑我定义为应替换的库存文本的文本。它不考虑在框中输入的新字母:
def buildUI(self, *args):
self.widgets["bs"] = cmds.textField (tx= "Replace me", editable= True, )
self.widgets["blendshape_name"] = cmds.textField(self.widgets['bs'], q=True, text=True)
cmds.button(label="Create BlendShape ", w=295, h=30, al="center", c=self.blendShape)
def blendShape (self, *args):
cmds.blendShape ( cmds.ls(sl=True)[1], cmds.ls(sl=True)[0],frontOfChain=True, n= self.widgets["blendshape_name"] )
最佳答案
仅当您运行buildUI函数时才查询blendshape_name。每次点击时您都必须读取文本字段。因此在函数blendShape中查询blendshape_name:
def blendShape(self, *args):
blendshape_name = cmds.textField(self.widgets['bs'], q=True, text=True)
cmds.blendShape(cmds.ls(sl=True)[1], cmds.ls(sl=True)[0], frontOfChain=True, n=blendshape_name)
关于python - 使用文本字段中的文本进行命名 - Maya python,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31533436/