2
Maya Python에 익숙해지기 위해이 책 (http://www.maya-python.com/)을 읽었습니다. 온라인 pdf가 있습니다 ... For the Statement) 올바른 결과를 얻지 못하고 있지만 오류가 발생하지 않습니다. 누군가가 이것을보고 나에게 문제를 일으키는 것에 대한 아이디어를 줄 수 있다면 큰 일 것입니다.Maya Python의 노드 이름 변경
그래서 3 개의 파일 노드를 만들고 3 개의 노드 이름을 모두 'dirt_'접두어로 변경해야합니다. 그러나 그것은 단지 '파일 1'이 아닌 다른 두 노드 여기
의 이름을 변경하는 과정입니다 :#The FOR statement
import maya.cmds;
def process_all_textures(**kwargs):
pre = kwargs.setdefault('prefix', 'my_');
textures = kwargs.setdefault('texture_nodes');
new_texture_names = [];
for texture in textures:
new_texture_names.append(
maya.cmds.rename(
texture,
'%s%s'%(pre, texture)
)
);
return new_texture_names;
#create new Maya scene & list 3 file nodes & print their names
maya.cmds.file(new=True, f=True);
textures = [];
for i in range(3):
textures.append(
maya.cmds.shadingNode(
'file',
asTexture=True
)
);
print(textures);
#pass new texture list to process_all_textures() func and print resulting names
new_textures = process_all_textures(
texture_nodes = textures,
prefix = 'dirt_'
);
print(new_textures);
[u'file1', u'file2', u'file3']
[u'dirt_file1']
감사합니다. 내가 따르고있는 책은 들여 쓰기를 표시하지 않기 때문에 나는 그 눈을 계속 지켜봐야 할 것 같다. – Mogie
Return 문은 일단 충족되면 기능을 중지한다. 그 이유는 매번 첫 번째 루프에서 멈 춥니 다. – DrWeeny