maya スクリプト Pythonメモ
スクリプト書くときによく使うやつのメモ
selection = cmds.ls(sl=True) #hogeは任意の変数 #今開いているmayaシーンのパス取得 pm.Env().sceneName() #選択しているメッシュがバインドされているなら値を返す hoge = cmds.listConnections(selection[0]+".inMesh",s=True, d=False) #選択されているものがメッシュなら値を返す hoge = cmds.listRelatives(selection[0], s=True, pa=True, type='mesh') #選択されているものがジョイントなら値を返す hoge = cmds.objectType(selection) == "joint": #ポップアップみたいなのを出す confirm = mc.confirmDialog( title=u'注意',essage=u'このツールは新規sceneでは起動できません。sceneを開くか、1度sceneの保存を行ってください',button=['OK'],defaultButton='OK') #選択されているメッシュのスキンクラスターを取得 selection = cmds.ls(sl=True) mesh = selection[0] shapes = cmds.listRelatives(mesh, shapes=True, noIntermediate=True) histories = cmds.listHistory(shapes[0], pruneDagObjects=True, interestLevel=2) skincluster = cmds.ls(histories, type="skinCluster") or [] #スキンクラスターが存在しないメッシュに使うとエラー起きるので、 or [] で空のリスト作ってます #intをstrに変える count = 1 count = str(count) #webサイトを開く import webbrowser webbrowser.open("https://~") #シーンファイルのインポート path = Z:\~~~\test.ma cmds.file(path, i = True, f=True) #指定したディレクトリ内のデータをリスト化して取得 os.listdir(path ) #シーン内に存在するジョイント名をリスト化して取得 hoge= cmds.ls(type= "joint") #ジョイント生成 cmds.joint(n="hip", p=(0,0,0,)) #リスト内逆転 hoge.reverse()