Getting this error

18 views
Skip to first unread message

Diana Chacha

unread,
Apr 24, 2013, 11:26:29 PM4/24/13
to python_in...@googlegroups.com
Hello
I am getting this error when I run my following code. Could somebody help me figure out what I could add or replace since it did work before now it is not.
CODE THAT I WANT TO RUN:
import maya.cmds as cmds

def main():
root_LOC=cmds.spaceLocator (n = 'root_LOC', r = 2)
cmds.move (0, 18.485, -2.815, 'root_LOC', relative=True)
print root_LOC
root_JNT=cmds.joint (n = 'root_JNT', r = 2)
cmds.move (0, 18.485, -2.815, 'root_JNT', worldSpace=True)
print root_JNT
root_CTL=cmds.circle(n = 'root_CTL', r = 2)
cmds.move (0, 18.485, -2.815, 'root_CTL',objectSpace=True, relative=True)
print root_CTL

main()

ERROR I AM GETTING:
# Error: 'list' object is not callable
# Traceback (most recent call last):
# File "<maya console>", line 14, in <module>
# File "<maya console>", line 4, in main
# TypeError: 'list' object is not callable #

br...@fie.us

unread,
Apr 24, 2013, 11:41:27 PM4/24/13
to python_in...@googlegroups.com
If I paste this code into my console, I don't get an error.

perhaps you have accidentally modified the "cmds" module in memory. Maybe you've set a function to a list.

-brad

Diana Chacha

unread,
Apr 24, 2013, 11:56:49 PM4/24/13
to python_in...@googlegroups.com
I will try that, but it was working find before. Did you run it in maya?


--
You received this message because you are subscribed to a topic in the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/python_inside_maya/kC3e3AYx214/unsubscribe?hl=en-US.
To unsubscribe from this group and all its topics, send an email to python_inside_m...@googlegroups.com.
To post to this group, send email to python_in...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

br...@fie.us

unread,
Apr 24, 2013, 11:58:12 PM4/24/13
to python_in...@googlegroups.com
Yes… otherwise I think it would have bombed upon importing maya.cmds…

You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.

DayDreamer

unread,
Apr 25, 2013, 12:10:59 AM4/25/13
to python_in...@googlegroups.com
I also didn't find any error.
But I like to point out couple other things in your code.

1. root_LOC=cmds.spaceLocator (n = 'root_LOC', r = 2)


cmds.move (0, 18.485, -2.815, 'root_LOC', relative=True)

> here, you making a loctor in maya and assigning it to the variable name root_LOC, but in the next line(cmds.move), you using the string name of the locator, which is not so appropriate way of doing the stuff. Use the variable name itself.And if the any node of name 'root_LOC' already exists in scene, the line 1 will create a locator with different name and your line 2 will move the old node having name 'root_LOC'.

use,

root_LOC=cmds.spaceLocator (n = 'root_LOC', r = 2)

# here is the change
cmds.move (0, 18.485, -2.815, root_LOC, relative=True)


2. cmds.move (0, 18.485, -2.815, root_LOC, relative=True)
> use xform command to do the job instead of the move command.

DayDreamer

unread,
Apr 25, 2013, 1:01:30 AM4/25/13
to python_in...@googlegroups.com
Edit:-
The Move command should be
cmds.move (0, 18.485, -2.815, root_LOC[0], relative=True)

Geordie Martinez

unread,
Apr 25, 2013, 2:08:26 AM4/25/13
to python_inside_maya
the error you're getting is telling you that root_LOC is a list of strings.
the move command wants what's  IN the list. Not the list itself. Just the first item in the list.
what the spaceLocator command is returning is a list of strings

[u'root_LOC'] # <-- see how this is a list

root_JNT # and this isn't

[u'root_CTL', u'makeNurbCircle1'] # <- the circle keeps its construction history as the second in the list so there are two items.



you can fix it quick by adding [0] to the end of your command like this:
root_LOC=cmds.spaceLocator (n = 'root_LOC', r = 2)[0]

and to the root_CTL command like this:
root_CTL=cmds.circle(n = 'root_CTL', r = 2)[0]

this lets you "index into" the the first item in the list that the spaceLocator (or any) command returns.
you'll still need to DE SELECT the locator first before making the joint or the joint will end up inside the locator.

BUT...
another way is to use pymel which is a whole lot simpler (in my opinion):

import pymel.core as pm
def blah():
    """ put your notes here.  inside TRIPLE quotes you can put anything!! """
   
    # CREATE A SPACE LOCATOR
    root_LOC=pm.spaceLocator(n='root_LOC')
   
    # MOVE IT IN SPACE TO SOME LOCATION
    root_LOC.setTranslation((0, 18.485, -2.815))
    print(root_LOC)
   
    # DESELECT IT OR THE JOINT WILL BE A CHILD OF THE LOCATOR
    pm.select(d=True)
   
    # MAKE THE JOINT
    root_JNT=pm.joint(n='root_JNT')
   
    # MOVE IT TO THE SAME POSITION AS THE root_LOC by getting the root_LOC's translation
    root_JNT.setTranslation(   root_LOC.getTranslation()   )
    print(root_JNT)
   
    # MAKE A NURBS CURVE
    root_CTL=pm.circle(n='root_CTL')[0]
   
    # MOVE THAT NURBS CURVE TO THE SAME SPOT AS THE JOINT
    root_CTL.setTranslation(   root_JNT.getTranslation()   )
    print(root_CTL)

blah()

Hope this was helpful. It's worth the struggle to learn python!



Reply all
Reply to author
Forward
0 new messages