Introduction to Python Scripting in Maya – Part 1: Creating and Manipulating Objects

In this movie, we introduce the basics of Python Scripting by showing how to create and manipulate a cubic mesh. We also cover how to create randomly positioned instances of the same cube using a Python script.

Files Used:


Christopher says:

This is a nice tutorial on using the SDK in Maya, never seen one like this for Softimage.

Devin du Plessis says:

Hi firstly thanks this is my first bit of coding and you’ve done it superbly. Only one thing I am having trouble understanding. In your for loop you have – for i in range(0, 50): what is the i? I replaced it with instanceResult which seemed to make more sense to me and it worked which is fine but I’d like to just understand what you did there please.

warpmaster7 says:

where do we paste the code in the script? sorry. Im new to maya so I havn’t really looked into scripting

Mark Mark says:

for i in range( 0, 50 ):
    instanceResult = cmds.instance( transformName, name=transformName + ‘_instance#’ )    
    cmds.move( 0, 1, 0, instanceResult )

and myCube1 have 0,0,0 position, but all instances – 0,1,0. why is this happening?

HitomiAyumu says:

Lucky im studying computer science. Thanks for this Autodesk.

Bars Timpson says:

Hello! Thank you for this great tutorial.
I need to merge around 200 cubes together but the Union feature can be used with only two polygons at a time. I tried using the command: cmds.nurbsBoolean( ‘nurbsCube1’, ‘nurbsCube2’, nsf=1, op=0 ) but I can’t seem to figure out how to script that in python in a ‘for’ loop since the name of the polygons changes each time. I would really appreciate your help with this.

Dave Yost says:

When the Python tab is selected, Maya should print in Python instead of MEL. We shouldn’t have to do the error-prone busywork of translating by hand from MEL to Python.

Lijian Wu says:


Zlatan Stajić says:

Is it possible to add rotation of these objects? 

M. Schulze says:

Could this be done with Fluid 3d Containers as well? 


I would love if someone could make a tutorial for debugging python in Maya and Eclipse or some other free IDE (cause doing it through code with pdb.set_trace() is inefficient and slow for more complex debugging :(((( ).

Jason Lee says:


Thomas Heaven says:

Whats defines wether i should use Python instead of MEL or vice versa? are there any advantages/disatvantages? (Sorry, newbie here.)

ithenoob says:

Very clear and helpful.

David Potschka says:

Thanks for the help Hugh

Tarje Pladsen says:

Hi. Is there any way to print the result without having to add the extra lines of code every time you want to see the result?
This seems to be a lot more cumbersome than how it used to be in older versions of maya…

Shunxu Huang says:

Hi, thanks for your video! and I have a question, I learnt c and c++ but have no experience with python, will I be able to follow alone? or should I learn python before I jump into maya script?

blossom ghuntla says:

‘attribute error module object has no attribute ls’ and I am getting same error for all codes but my selection works on LRA toggle what is the probel sir

Dacian Popute says:

Your code is not following PEP8 convention.

Spandan Pattnaik says:

Is this free?

Andrew Greenlee says:

I work in Animation and Film and I find your material PERFECT! I’ve been wanting to learn, but books etc have not been proper motivation, you’re really fast-tracking me in combination with other basic python tutorials. Thank you so much, this deserves to be endorsed by Autodesk and I’m happy the resources have been getting better in recent years. I’m not a robot, at least not in metallic form, thank you.

Coloured Stone says:

Thanks very much for your tut. It would be great if at the end of the tut you could show the script in it’s entirety so I can more easily find where I went wrong.

Gogo says:

if only most other tutorial vids were this clear and easy to understand.

Ben Müller says:

Hi, thanks for the nice Video.
Until 7:30 all went right but when i want to run the script, Maya says there is an invalid syntax in line 1. But im sure I can´t do everything wrong at the 1st line.

Erik Martines Sanches says:

Nice. I’m curious about debugging in a code edtor.

이윤신 says:

clean coding, I love it >_< !


import maya.cmds as cmds

result = cmds.polyCube(w=4.9277,h=2.927,d=4.740,name=’mypolycube#’)

print’result:’ +str(result);
// Error: result = cmds.polyCube(w=4.9277,h=2.927,d=4.740,name=’mypolycube#’)
// Error: Line 3.8: Syntax error //

mattlowery says:

Why do you type x= random.uniform? why not just x= random?

melodyss maya says:

good!Professional, also with the subtitles!

Daniel Burnett says:

I am using Maya 2016, I am in script editor but there is no python tab. What do I do?

Ming Jun says:

Hello , may I please know if I can program on maya with a macbook pro ?

Matthew V.C says:

Hey! I’m currently taking Digital Graphics and Animation. See, we’re working in Maya for a lot of our projects. I recently was given a room to work on and in my room I was told to create a baby grand piano. I was wondering if you could help me with that. I thought that using this could help me in this project. But see whenever I get to the part where you finish the myCube name and delete the cube, “//Error: Line 3.8: Syntax error”

Hugh Ekeberg says:

You should select the tiny gear icon on the bottom right hand corner of the video and that will allow you to select 720 pixels high definition. Otherwise the video defaults at 480 pixels.

 Write a comment


Do you like our videos?
Do you want to see more like that?

Please click below to support us on Facebook!