2017-03-25 4 views
0

Vray를 사용할 때 지루한 작업을 단순화하는 스크립트를 작성하고 있지만 사용자가 int 값을 입력 할 때 intFields를 사용하여 특정 작업을 시작할 때 입력 할 수 있도록해야합니다. 단추. 필요한 부분 만 코드를 단순화했습니다. 값을 어떻게 변경하든 스크립트 편집기 출력에서 ​​항상 0입니다.intField가 변경 내용을 표시하지 않습니다.

import maya.cmds as cmds 

idManagerUI = cmds.window(title='Vray ID Manager', s = False, wh = (300,500)) 

cmds.columnLayout(adj = True) 

cmds.text (l = 'type in MultimatteID to select matching shaders \n or specify ObjectID to select matching objects \n __________________________________________ \n') 

cmds.text (l = 'MultimatteID: \n') 
cmds.intField("MultimatteID", editable = True) 
MultimatteIdButton = cmds.button(l = 'Go!', w = 30, h = 50, c = 'multimatteChecker()') 
cmds.text (l = '\n') 

cmds.showWindow(idManagerUI) 

MultimatteIdInput = cmds.intField("MultimatteID", q = True, v = True) 


def multimatteChecker(): 
    print MultimatteIdInput 

답변

0

세 가지 :

먼저, intField MultimatteID 실제로 당신이해야한다고 생각 이름을 받고 있음을 확신 할 수 없다 작성한다. 마야 위젯 이름은 마야 개체 이름과 같이 고유합니다. 이름이 MultimatteID 일 수 있지만 이름이 MultimatteID2 인 실제 위젯을 다시 가져올 수 있습니다. 비슷한 이름의 컨트롤을 사용하여 삭제되지 않은 창을 표시하거나 숨길 수 있기 때문입니다.

둘째, 붙여 넣은 코드는 창을 만든 직후 컨트롤의 값을 쿼리합니다. 항상 작성시 부여한 값을 인쇄해야합니다.

마지막으로 버튼에 명령 지정 문자열 버전을 사용하지 마십시오. 리스너의 코드에서 작업 스크립트로 이동할 때 신뢰할 수 없습니다.

idManagerUI = cmds.window(title='Vray ID Manager', s = False, wh = (300,500)) 
    cmds.columnLayout(adj = True) 
    cmds.text (l = 'type in MultimatteID to select matching shaders \n or specify ObjectID to select matching objects \n __________________________________________ \n') 
    cmds.text (l = 'MultimatteID: \n') 
    # store the intField name 
    intfield = cmds.intField("MultimatteID", editable = True) 
    cmds.text (l = '\n') 

    # define the function before assigning it. 
    # at this point in the code it knows what 'intfield' is.... 
    def multimatteChecker(_): 
     print cmds.intField(intfield, q = True, v = True) 

    #assign using the function object directly 
    MultimatteIdButton = cmds.button(l = 'Go!', w = 30, h = 50, c = multimatteChecker) 
+0

슈퍼 :

이것은 당신이 원하는 일을해야한다. 그것은 작동합니다. 고맙습니다 :) – leabum