2017-12-15 4 views
-1

표현 결과를 헤드 업 디스플레이로 사용하기 위해 Maya 텍스트 오브젝트로 파이프 처리하려고합니다. 내 스크립트는 스크립트 편집기에서 작동하지만 명령 줄이나 디스플레이 표현식에서 호출 할 때는 작동하지 않습니다. 명령 줄에서이 기능을 사용하려면 어떻게 변경해야합니까?코드는 스크립트 편집기에서 작동하지만 명령 행에서 실행되지 않는 경우

import maya.cmds as cmds 

# convert a string to hex values, separated by a space 

typeNode = cmds.ls(selection=True) 
type3d = cmds.listConnections(t='type') 
typeValue = cmds.getAttr('tower_CON.Spin') 

valueList=list(str('{:3.2f}'.format(typeValue))) 

hexVersion="" 

for x in valueList: 
    hexValue=x.encode("hex") 
    hexVersion=hexVersion + hexValue + " " 

cmds.setAttr(str(type3d[0]) + ".textInput", hexVersion.rstrip(), type="string") 
+0

명령 줄에서 사용하는 명령은 무엇입니까? 예상되는 행동은 무엇입니까? 실제 행동이란 무엇입니까? 오류가 있습니까? – Quelklef

+0

명령 줄에서 실행하려고하면 어떻게됩니까? 실행중인 명령과 cli가 제공하는 명령을 게시하십시오. – mypetlion

+0

python 명령 줄에서 다음과 같이 실행합니다 : textToolHUD() 결과 : textToolHUD() # 오류 : TypeError : 파일 줄 1 : '모듈'객체를 호출 할 수 없습니다. # – sfillat

답변

1

오류로 인해 모듈이 기능으로 실행되는 것 같습니다.

import maya.cmds as cmds 

def text_to_hud(): 
    # convert a string to hex values, separated by a space 

    typeNode = cmds.ls(selection=True) 
    type3d = cmds.listConnections(t='type') 
    typeValue = cmds.getAttr('tower_CON.Spin') 

    valueList=list(str('{:3.2f}'.format(typeValue))) 

    hexVersion="" 

    for x in valueList: 
     hexValue=x.encode("hex") 
     hexVersion=hexVersion + hexValue + " " 

    cmds.setAttr(str(type3d[0]) + ".textInput", hexVersion.rstrip(), type="string") 

다음 명령 줄에서이 같이

import textToolHUD as th; th.text_to_hud() 

당신은 또한 파일을 유지할 수 싶어 그냥

을 수행

당신은 아마 파일이 저장해야

import textToolHUD 

하는 번 을 실행하지만, 나쁜 쪽의 것 코드를 가져올 때 실행되는 ractice.

+0

감사합니다! 나는 당신의 첫 번째 제안을 사용하고 있습니다. – sfillat

+0

다음 독자에게 받아 들여지는 것으로 표시해야합니다. – theodox

+0

thanks @theodox – sfillat

0

대부분의 경우 종속성이 누락되었습니다. 실행 :

pip install maya 
관련 문제