Maya Training

Introduction to Hard Surface Modeling

Maya Training

Interiors and Furniture Vol 1 & 2 - Modeling & Cloth

Maya Training

Shading, Lighting and Rendering the Bedroom in MR

Maya Training

Robot volume one - Modeling with animation in mind

Maya Training

Spach-Alspaugh House the complete courseware

Maya Training

Burt The Cartoon Dinosaur Vol 01 - Modeling

New Maya Training

Robot Volume 02 - Hybrid Rigging
You are here > Home > SimplyMaya Community Forums
Loading

Welcome to Simply Maya

Please Sign in or Sign up for an account

Member Login

Lost your password?

Not a member yet? Sign Up!

Old 26-02-2010, 08:26 PM   #1
elephantinc
Level 32 pachyderm
 
elephantinc's Avatar
 
Join Date: Dec 2007
Location: England
Posts: 1,859
Thanks: 12
Thanked 43 Times in 37 Posts
Default 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
elephantinc is offline   Reply With Quote
Old 26-02-2010, 09:58 PM   #2
stwert
EduSciVis-er
 
Join Date: Dec 2005
Location: Toronto
Posts: 3,371
Thanks: 74
Thanked 709 Times in 642 Posts
Default

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?
stwert is offline   Reply With Quote
Old 26-02-2010, 10:46 PM   #3
elephantinc
Level 32 pachyderm
 
elephantinc's Avatar
 
Join Date: Dec 2007
Location: England
Posts: 1,859
Thanks: 12
Thanked 43 Times in 37 Posts
Default

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)
elephantinc is offline   Reply With Quote
Old 26-02-2010, 11:40 PM   #4
ctbram
Moderator
 
ctbram's Avatar
 
Join Date: Jan 2004
Location: Michigan, USA
Posts: 2,995
Thanks: 42
Thanked 582 Times in 532 Posts
Default

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.
ctbram is offline   Reply With Quote
Old 27-02-2010, 12:00 AM   #5
elephantinc
Level 32 pachyderm
 
elephantinc's Avatar
 
Join Date: Dec 2007
Location: England
Posts: 1,859
Thanks: 12
Thanked 43 Times in 37 Posts
Default

Thanks that worked
I thought just doing

commText()
commText.update(timer)

would work.

elephantinc is offline   Reply With Quote

A little bit about who we are
Links you might find useful
Catch up with SimplyMaya
SimplyMaya specialises in Maya tutorials. We offer over 1,000 individual Maya training videos, ranging from basic Maya tutorials through to intermediate Maya tutorials. Our tutorials are created by instructors with industry experience and are designed to get you up and running in Maya quickly without making it seem like hard work.

Copyright © 1999-2015 SimplyMaya - vBulletin® Copyright © 2000-2015, Jelsoft Enterprises Ltd.