我試圖根據場景中存在的燈光數量在窗口中創建按鈕。 當我按創建按鈕我得到這個錯誤(#RuntimeError:沒有指定對象名稱#。):在窗口中創建動態按鈕
Traceback (most recent call last): File "C:\Program Files\Autodesk\Maya2015\Python\lib\site-packages\pymel\internal\factories.py", line 779, in callback res = origCallback(*newargs)
File "", line 31, in lightLst
File "", line 17, in updateList
File "C:\Program Files\Autodesk\Maya2015\Python\lib\site-packages\pymel\internal\factories.py", line 806, in newUiFunc return beforeUiFunc(*args, **kwargs)
File "C:\Program Files\Autodesk\Maya2015\Python\lib\site-packages\pymel\internal\factories.py", line 947, in newFuncWithReturnFunc res = beforeReturnFunc(*args, **kwargs)
File "C:\Program Files\Autodesk\Maya2015\Python\lib\site-packages\pymel\internal\pmcmds.py", line 134, in wrappedCmd res = new_cmd(*new_args, **new_kwargs)
RuntimeError: No object name specified. #
我有點堅持了下來,我無法找到我問題的解答。這裏是代碼:
import maya.cmds as cmds
import maya.mel as mel
import pymel.core as pm
class createWindowClass(object):
def __init__(self, *args):
pass
def show(self):
self.createWindow()
def turnOn(totalLgt, *args):
print "Enter turnOn"
def turnSolo(totalLgt, *args):
print "Enter turnSolo"
def updateList(name, totalLgt, *args):
print "update %s" % name
self.button = pm.button(label="ON", e=True, command = lambda *args: turnOn(totalLgt))
self.button = pm.button(label="SOLO", e=True, command = lambda *args: turnSolo(totalLgt))
def lightLst(*args):
totalLgt = 0
#list all lights in scene
lis = pm.ls(type='light')
print lis
for lgt in lis:
totalLgt += 1
nameLgt = lgt.longName()
name = nameLgt.split("|")[1]
print name
updateList(name, totalLgt)
#CREATE WINDOW
def createWindow(self):
windowID = 'Light Control'
if pm.window(windowID, exists = True):
pm.deleteUI(windowID)
pm.window(windowID, title = "Modify Lights", width = 100, sizeable = True)
pm.rowColumnLayout(numberOfColumns=1, columnWidth=[(10,120)], columnOffset=[10,"right",5])
pm.text(label=" ******** Light list ******** \n")
pm.button(label="CREATE", command = lightLst)
pm.text(label= " \n ***************************** \n ")
window_obj = pm.window(windowID)
window_obj.show()
cls = createWindowClass()
cls.show()
如果有人可以帶來一些光它,我真的會讚賞它!
謝謝!但不是真正的,如果我得到它的權利我加我自己的方法,但現在當它進入updateList我得到這個錯誤: #RuntimeError:控件必須有佈局。在窗口中找不到佈局:# – Urd
在'lightLst'方法中,您還必須編寫'self.updateList(name,totalLgt)' –
yes!已經這樣做也<>(斯里我忘了說) – Urd