object properties

hi all,

i have a few days free, so I thought I’d start teaching myself scripting with Blender.

Running into a problem though: I can’t find a list of object properties anywhere (e.g. LocX, LocY etc).

I can’t believe there’s not a list somewhere! Can someone point me to it? Or tell me how to list an objects properties in a script?

Thanks,

Leon

Use the dir() function to return a list of the properties of an object.


import Blender

obj = Blender.Object.Get("blah")
print dir(obj)

Martin

hi,

thanks for the info: but that seems to give me the methods rather than the properties like RotX, LocX and so on. Or is simply that I should look in the IPO window?

The reason I’m asking is that I’m going to have very limited internet access for the next two weeks. If the weathers bad and I have to limit my fishing and shooting etc, I wanted to carry on with the programming!!!

cheers

leon

it gives you the methods, yes, and about half of those methods are used to return values like rotation, location and size.

print obj.getLocX()
print obj.getLocY()
print obj.getLocZ()

Martin

hi theeth,

thanks: my apologies for being a dummy here! My only real exposure to object oriented programming has been microsoft visual basic…

I followed the basic tutorials where they were using values directly (like obj.RotX = 1.5 for example). I assumed rather stupidly this was the way to do things!

Looks like I can do what I need with get / set, but just out of interest, are all values accessible through get/set methods now?

cheers

Leon

yep, pretty much.

This is a fail-safe method, since the function check if the value is correct before assigning it to the property.

Martin