PDA

View Full Version : unicode' object is not callable!! in Python


saedAbdelhafez
04-15-2009, 12:29 AM
hello people
i was running this Python script in maya2009 and it worked but after i restart maya
it gave me an error "# Error: 'unicode' object is not callable"
can any one till me what dose that mean

thank you

import maya.cmds as cmds
window=cmds.promptDialog(m="Enter Number Of AX",b="O.K")
if window =="O.K":
.............numberOfTeeth=cmds.promptDialog(q=True,tx=True)
.............numberOfTeeth=int(numberOfTeeth)
.............Gear=cmds.polyPipe(sa=numberOfTeeth)
.............base=cmds.getAttr(Gear[1]+".sa")
.............min = base * 2
.............max = (base * 3)-1
.............cmds.select(cl=True)
.............for i in range(min,max,2):
........................cmds.select(Gear[1]+".f[%d]"%i,add=True)
.............cmds.polyExtrudeFacet(ltz=1)
.............cmds.select(cl=True)
else:
print numberOfTeeth

Chadrik
04-15-2009, 03:48 PM
have you tried restarting Maya and running your script again? i just ran it in 2009 and (after changing the second Gear[1] to Gear[0]) it ran just fine. the error you are getting can occur when you accidentally override a function with a string ( unicode is a type of string )

cmds.select = 'foo'
cmds.select()
# Error: 'str' object is not callable
# Traceback (most recent call last):
# File "<maya console>", line 1, in
# TypeError: 'str' object is not callable #

saedAbdelhafez
04-15-2009, 06:53 PM
Gee i dono how did i missed it :) thankx alot bro ..

saedAbdelhafez
04-15-2009, 07:59 PM
it happened again :( ... it worked then i did it lately it didn't work !!

Chadrik
04-15-2009, 11:17 PM
my guess would be that you are using the name range as a variable in some other script.

try this:

print range

you should get this:

<built-in function range>

CGTalk Moderation
04-15-2009, 11:17 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.