# Serpens ドキュメント Update date 2020/08/11 [Serpens ドキュメント(English)](https://hackmd.io/s/Hkn_t_wxX) ## エラーが発生しやすいコード一覧 ### 引数に変数を代入すると、次のエラーが発生することがあります。 #### mel ![](https://i.imgur.com/byMovRL.png) ```c= $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 ![](https://i.imgur.com/PYdaqoQ.png) ```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')) ``` #### Error code: ```python= # 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]** というように要素を取り出す必要があります。 ```python= arrowGRP = str(cmds.group(Sphere_, p=Cube_[0], n='test')) ``` もう一つの対策としてはmelのコードを以下に変更します #### mel ```c= $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 ```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')) ```