You're blocking ads, which pay for BlenderNation. Read about other ways to support us.

Maya to Blender Conversion Script

8

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

  1. 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.

    • 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

    • 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 :)

  2. 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

Leave A Reply

To add a profile picture to your message, register your email address with Gravatar.com. To protect your email address, create an account on BlenderNation and log in when posting a message.