property problem

Scripting in Blender with Python, and working on the API

Moderators: jesterKing, stiv

mbibim
Posts: 11
Joined: Thu Apr 10, 2003 11:57 pm

property problem

Postby mbibim » Tue May 20, 2003 6:42 pm

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²

verence
Posts: 34
Joined: Thu Nov 07, 2002 12:42 pm

Re: property problem

Postby verence » Wed May 21, 2003 12:38 pm

hi,

do you get an attribute error? maybe the property name does not match (but i do not think so). first, use a

Code: Select all

print dir(ow)
to find out if your object really has this property. second use

Code: Select all

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]

mbibim
Posts: 11
Joined: Thu Apr 10, 2003 11:57 pm

Postby mbibim » Fri May 23, 2003 10:26 am

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²

verence
Posts: 34
Joined: Thu Nov 07, 2002 12:42 pm

Postby verence » Fri May 23, 2003 1:05 pm

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


Return to “Python”

Who is online

Users browsing this forum: No registered users and 1 guest