Friday, October 21, 2011

Errors : Commands

Maya doesn’t arbitrarily execute a random “command” that you enter into the Command Line. To illustrate, let’s try to create a cube, instead of a sphere, using the same method we used in the previous post. 

Let’s address the concerns we should be thinking about:
  • Why a cube won't appear when we type cube?
  • Why a cube will appear when we type nurbsCube?
  • What are error messages, and what  do they mean? 
Command Error: An Example
In the last blog post, we used created a sphere in Maya by simply typing sphere into the Command Line. Naturally, you may think that simply typing cube into the Command Line will create a cube into the scene.
 
Let's find out:
    Click inside the Command Line.
    Type cube
    Press Enter

    Nothing happened!

    In fact, the Command Feedback Line turned red and a line of text appeared (see Figure 1 ):
    // Error: Cannot find procedure "cube".

    Figure 1: Error Message





    Valid Commands: An Example

    Let’s make the cube using a valid command: nurbsCube
    Click inside the Command Line.
    Type nurbsCube
    Press Enter



    Figure 2: Cube
    Awesome! 

    A cube appeared! (see Figure 2)

    But what gives? 

    How come it didn’t work when we typed cube?



    "Oohhh… that’s why nothing happened!” 
    In the case of cube, Maya doesn’t recognize it as a command – it simply isn’t in Maya’s library of procedures to execute the command, despite your intentions.  

    On the other hand, sphere is an actual command – it just coincidentally happens to make sense to us in the real world and in this particular example.

    Not all commands are as obvious as sphere. The command, nurbsCube, certainly wouldn't have been my first guess.  After all, if sphere works, why not cube? 

    Frankly, I don't know why the powers that be decided sphere would be a valid command, while cube wouldn't be; and that's not the point.  

    The point is:
    • we can’t simply type in something and expect Maya to do as we wish. 
    • Maya won’t make a cylinder, plane, or torus simply because we type cylinder, plane, or torus into the Command Line.
    The Error Message  
    The error message may seem cryptic, but completely illustrates this point:
    // Error: Cannot find procedure "cube".

    Maya has never heard of cube

    Sure, it may make sense to you – you want Maya to make a cube.  To Maya, though, you may as well be saying wqoe#irnddf?pw.  Arbitrary commands that we write into the Command Line or Script Editor won't always make sense to Maya, despite our intentions.

    We have to give Maya the “magic word(s)”, so to speak.  We have to give Maya proper and valid commands that it understands.

    Next Post:
    While we're on the topic of common problems, we'll address one of the notorious in the entire galaxy: Syntax Errors!

    No comments:

    Post a Comment