Try   HackMD

Serpens ドキュメント

Update date 2020/08/11
Serpens ドキュメント(English)

エラーが発生しやすいコード一覧

引数に変数を代入すると、次のエラーが発生することがあります。

mel

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

$Cube_=`polyCube -w 1 -h 1 -d 1 -sx 1 -sy 1 -sz 1 -ax 0 1 0 -cuv 4 -ch 1 -n "Cube"`; $Sphere_ = `polySphere -r 1 -sx 20 -sy 20 -ax 0 1 0 -cuv 2 -ch 1 -n "Sphere"`; string $arrowGRP = `group -n test -p $Cube_ $Sphere_`;

converted python

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

import maya.cmds as cmds Cube_ = cmds.polyCube(sz=1, sy=1, sx=1, d=1, cuv=4, h=1, n="Cube", ch=1, w=1, ax=(0, 1, 0)) Sphere_ = cmds.polySphere(cuv=2, sy=20, ch=1, sx=20, r=1, ax=(0, 1, 0), n="Sphere") arrowGRP = str(cmds.group(Sphere_, p=Cube_, n='test'))

Error code:

# Error: line 1: Invalid arguments for flag 'p'. Expected string, got [ unicode, unicode ] # Traceback (most recent call last): # File "<maya console>", line 11, in <module> # TypeError: Invalid arguments for flag 'p'. Expected string, got [ unicode, unicode ] #

関数Cube_のタイプはリストのため、上のコードのまま使用する場合は
Cube_ を Cube_[0] というように要素を取り出す必要があります。

arrowGRP = str(cmds.group(Sphere_, p=Cube_[0], n='test'))

もう一つの対策としてはmelのコードを以下に変更します

mel

$Cube_ = `polyCube -w 1 -h 1 -d 1 -sx 1 -sy 1 -sz 1 -ax 0 1 0 -cuv 4 -ch 1 -n "Cube"`; $Sphere_ = `polySphere -r 1 -sx 20 -sy 20 -ax 0 1 0 -cuv 2 -ch 1 -n "Sphere"`; string $arrowGRP = `group -n test -p Cube Sphere`;

converted python

import maya.cmds as cmds Cube_ = cmds.polyCube(sz=1, sy=1, sx=1, d=1, cuv=4, h=1, n="Cube", ch=1, w=1, ax=(0, 1, 0)) Sphere_ = cmds.polySphere(cuv=2, sy=20, ch=1, sx=20, r=1, ax=(0, 1, 0), n="Sphere") arrowGRP = str(cmds.group('Sphere', p='Cube', n='test'))