how can object properties be accesed in python?

the title says it all :smiley:

no it doesnt.
what properties do you want to acess?

You can read and write in properties if
you get it in a variable with Object.Get(Name) or
Object.GetSelected()[0] functions.

But properties format are not always the same. It can be
float, or list, or another objet. Try this code to see all
of them except ‘inverse’ which doesn’t exist, and matrix
which makes script crasch.

import Blender
from Blender import Object

Obj=Object.GetSelected()[0]

Vlist=dir(Obj)
print dir(Obj)


for property in Vlist:
   if property.find('inverse')==-1  and property.find('matrix')==-1: 
       print property,':',; exec "print str(Obj."+property+")"


To see an example of code to change the name of an object group (the rest of the text is in french, sorry, no time for translation):
http://jmsoler.free.fr/didacticiel/blender/tutor/python_renobject.htm

jm

that code’s not really what i need( i don’t even undertand what it does)

i just need to know how to read/write object properties, the ones in the realtime buttons

In the game engine? Why didn’t you say it?
Link this code to a sensor in the real time
engine.

import GameLogic 
    controller = GameLogic.getCurrentController() 
    owner = controller.getOwner() 
    print dir(owner)

Then you can see in in the console :

[‘applyImpulse’, ‘disableRigidBody’,‘enableRigidBody’,
‘getLinearVelocity’, ‘getMass’, ‘getMesh’, ‘getOrientation’,
‘getParent’,‘getPosition’, ‘getReactionForce’,‘getVelocity’,
‘restoreDynamics’, ‘setOrientation’, ‘setPosition’, ‘setVisible’,
‘suspendDynamics’]

You can use functions of this list to modify a lot of properties.

jm

PYTHON SCRIPT ERROR:
Traceback (most recent call last):
File “Text”, line 1, in ?
ImportError: No module named GameLogic

nothing seem’s to work for me anymore…

This scipt doesn’t work if it’s not linked to a sensor.
And you don’t need to do Alt-p to launch it.

1/ Select one object
2/ Go to the Realtime buttons
3/ Add a Sensor “Always”
4/ Add a Controller Python, and write the script name.
5/ link the sensor to the controler
6/ Pkey to enter in GameMode
7/ Esckey to stop GameMode

Look at the DOS console.

jm

hey!something finnally works!incredible!amazing!unbelieveable! :smiley: :smiley: :smiley: :smiley: :smiley: :smiley: :smiley: :smiley: :smiley: :smiley: