Previous Thread  Next Thread

chat icon property problem

mbibim

Posted: Tue May 20, 2003 5:42 pm
Joined: 10 Apr 2003
Posts: 11
Hello

I've posted this problem a month ago but no solution was found. So i ask this question again :

i'm working under blender 2.25 and i use python, but i can't access the value of my object's property (define in Real time button).
I've tried many python script but no solution. I think it should start like this:

import GameLogic

ow = GameLogic.getCurrentController().getOwner()
print ow.pousse ("pousse" is the name of the property)

but it doesn't work.
Please help me 'cause i really need to solve my problem.
thanks a lot.

biČ
Reply with quote


verence

Posted: Wed May 21, 2003 11:38 am
Joined: 07 Nov 2002
Posts: 34
hi,

do you get an attribute error? maybe the property name does not match (but i do not think so). first, use a
Code:
print dir(ow)
to find out if your object really has this property. second use
Code:

if hasattr(ow, "pousse"):
    print ow.pousse

because it could be that the object is not 'prepared'.

you should also keep in mind that property names are case sensitive.

hope that helps

[/code]
Reply with quote


mbibim

Posted: Fri May 23, 2003 9:26 am
Joined: 10 Apr 2003
Posts: 11
hy

thanx for your help. I've tried you suggestion with my camera which has a property (created in the real times button) called "perso". I wrota that :

from Blender import *

ow = Object.Get("Camera")

if hasattr(ow, "perso"):
print ow.perso

but the property wasn"t found . So that is not the solution to get a property. Probably i have to change the second line of my code. But how can I get my object in python in order to access his properties ???

thanx

biČ
Reply with quote


verence

Posted: Fri May 23, 2003 12:05 pm
Joined: 07 Nov 2002
Posts: 34
mbibim wrote:
hy

from Blender import *

ow = Object.Get("Camera")

if hasattr(ow, "perso"):
print ow.perso


biČ


Object.Get won't work to access properties. you need to fetch your object via

ow = controller.getOwner()

i do this a lot to display text via ow.Text = "hallo".

but i will have a look at it when i'm home.

greets
Reply with quote


 
Jump to:  
Powered by phpBB © 2001, 2005 phpBB Group