Maya 2020 fundamentals - modelling the real world
Get halfway through a model and find it's an unworkable mess? Can't add edge loops where you need them? Can't subdivide a mesh properly? If any of this sounds familiar check this course out.
# 1 26-02-2010 , 08:26 PM
elephantinc's Avatar
Level 32 pachyderm
Join Date: Dec 2007
Location: England
Posts: 1,859

Anyone know Python? Technical question.

Does anyone know how to call a function thats defined with in a class? I've tried myclass.myfunction() but that doesn't seem to work.

Any help will be greatly appreciated.
ElephantInc

# 2 26-02-2010 , 09:58 PM
EduSciVis-er
Join Date: Dec 2005
Location: Toronto
Posts: 3,374
That should be about right. Are there any parameters you need to specify, such as myclass.myfunction(var1)? What error message are you getting?

Oh yeah, and have you imported the class in your script?

# 3 26-02-2010 , 10:46 PM
elephantinc's Avatar
Level 32 pachyderm
Join Date: Dec 2007
Location: England
Posts: 1,859
error:
File "/Users/Elephant_Inc/Desktop/PhAT/main.py", line 270, in <module>
commText.update(timer)
TypeError: unbound method update() must be called with commText instance as first argument (got int instance instead)

My class is commText and the function is update (that needs the timer variable)
this is the line I'm using to call it: commText.update(timer)

# 4 26-02-2010 , 11:40 PM
ctbram's Avatar
Moderator
Join Date: Jan 2004
Location: Michigan, USA
Posts: 2,998
looks like you have not instantiated the commText class unless it is a static class you must instantiate it.

I have used python bit the syntax would be something like...

...
x = commText()
x.update(timer)
...


"If I have seen further it is by standing on the shoulders of giants." Sir Isaac Newton, 1675

Last edited by ctbram; 06-03-2010 at 06:50 AM.
# 5 27-02-2010 , 12:00 AM
elephantinc's Avatar
Level 32 pachyderm
Join Date: Dec 2007
Location: England
Posts: 1,859
Thanks that worked user added image
I thought just doing

commText()
commText.update(timer)

would work.

user added image

Posting Rules Forum Rules
You may not post new threads | You may not post replies | You may not post attachments | You may not edit your posts | BB code is On | Smilies are On | [IMG] code is On | HTML code is Off

Similar Threads