about maya python


#1

I learning a tutorial named “Building Maya Interfaces with Python”
[VIMEO]42848594[/VIMEO]
but when I run the scrpits in the maya ,there has a Error

Error: line 1: NameError: file C:/Users/Archangel/Documents/maya/scripts\exampleUI.py line 7: global name ‘exists’ is not defined

pleae help and thank you !


#2

If you cut and paste lines 5 to 9 from that script into your post (and use the # button to format it) then we will be able to point out what is probably a simple syntax error.

David


#3

Post the script here :slight_smile:


#4

Moved to the programming subforum.


#5

all of script:

import maya.cmds as cmds


def UI():
    
    #check to see if our window exists
    if cmds.window("exampleUI", exists - True):
        cmds.deleteUI("exampleUI")
        
        
        #create our window
        window - cmds.window("exampleUI" , title - "Example UI", w - 300, h - 300, mnb - False, mxb - False, sizeable - False)
        
        
        #show window
        cmds.showWindow(window)

#6

All those - should be =
With respect, I would go as far as suggesting that you should start with simpler tutorials before tackling a UI. Get to know the basic python syntax first.

David


#7

I do that and find the solution ! thanks!


#8

www.codeacademy.com
Go through the Python tutorial there - you will learn everything you need to know about Python for working with Maya.cmds or PyMEL.