This script by Alex Telford will convert Maya script to Blender Python.
Hi,Over the past year I have been working on creating an api to allow Maya scripts to work in Blender which has become indespensible in my workflow, so I would like to share this out in the hopes that it will encourage more artists to write scripts for Blender, and encourage more Maya programmers to create Blender compatible versions of their tools.
Some stats:
- 4347 lines
- 1005 lines of docstring
- 63 functions
- 33 sub functions
- 6 classes
Enjoy, and I am about to leave for a few weeks on holiday (At last) so my apologies if I do not reply to questions in a timely manner.
8 Comments
Alex thank you, we really need this specially if most of you background work done in maya, lets take a look at it and improvement it..
Thanks for sharing it's a very handy tool.
You are most welcome, and yes the vast majority of my developer experience is in Maya animation, I'll keep working on this script and add new functions as I create them.
Woooot?, sounds great, gonna have to field test it... Does it turn mel unto bpy or maya python into bpy?
See my reply to Charlie, this is python not mel, though mel easily converts to python
the mel line:
listRelatives -c -ad "pCube1";
Converts to python:
cmds.listRelatives("pCube1", c=True, ad=True)
Which will work in the blender cmds
So, you type in a Maya script, and a blender python script comes out?
Sounds amazing!
Sorry for the confusion, no, this doesn't 'convert' anything in that sense.
What is does is replicate maya's utility functions in blender, so most object-level scripts you can easily alter to run in blender.
For example, the maya command:
import maya.cmds as cmds
becomes:
import blender.utils.cmds as cmds
lines like:
allChildren = cmds.listRelatives('myCube', children=True, allDecendants=True)
Will work in both maya and blender
The cmds code converts strings to objects so:
'Cube.001.rotateX' converts to: tuple(bpy.data.objects["Cube.001"], 'rotationX')
Things that you will need to update manually:
selection = cmds.ls(sl=1)
name = selection[0].rsplit('|', 1)[-1]
Becomes:
selection = cmds.ls(sl=1)
name = selection[0].name
Although I could make an auto converter script I'd like to finish creating the component level functions first. Besides auto converters don't work very well most of the time anyway :)
Well, it did sound too good to be true... :-)
HI Alex,
Alex thank you for developed concept. I want one help. how to use bpy module in maya. i want run some of blender python scripts inside of maya. if you know please let me know.
Thanks,
Babu