exploring armature module

Scripting in Blender with Python, and working on the API

Moderators: jesterKing, stiv

Haunt_House
Posts: 27
Joined: Tue Oct 22, 2002 9:03 am

exploring armature module

Postby Haunt_House » Tue Jul 29, 2003 11:54 pm

Hi

I try to use the Armature module, but I get stuck.

Is there any documentation?

I am certain there was a way to print out all possible attributes (LocX LocY RotZ and so on) of a module/object, whatever. What's the syntax for that?

print dir () seems to only do functions.

thanks in advance

Haunt_House

theeth
Posts: 1184
Joined: Wed Oct 16, 2002 5:47 am
Location: Montreal
Contact:

Postby theeth » Wed Jul 30, 2003 3:48 am

well, you can always try creating an armature and using:

Code: Select all

import Blender

armature = Blender.Armature.Get()[0]
print dir(armature)


Of course, if you don't know how Get work:

Code: Select all

import Blender

print Blender.Armature.Get.__doc__


Martin
Life is what happens to you when you're busy making other plans.
- John Lennon

Haunt_House
Posts: 27
Joined: Tue Oct 22, 2002 9:03 am

Postby Haunt_House » Wed Jul 30, 2003 7:13 pm

well, that gives me some functions. But the attributes stay hidden.

you see, I just want to change the root of a bone, for example.

Is it just me, or are the new modules totally useless without documentation? Sorry, but I don't want to search the source code, just because I want to use a python module. This searching costs a damn amount of time. And until now it was futile.

sigh

Haunt_House

theeth
Posts: 1184
Joined: Wed Oct 16, 2002 5:47 am
Location: Montreal
Contact:

Postby theeth » Wed Jul 30, 2003 7:55 pm

not to sound rude or anything, but it took me a whole 2 min to do what you want to do, knowing nothing of the Armature module to start with.

Creating a random armature beforehand.

Code: Select all

import Blender

print dir(Blender.Armature)

['Bone', 'Get', 'New', '__doc__', '__name__', 'get']


Code: Select all

import Blender

print Blender.Armature.Get.__doc__

(name) - return the armature with the name 'name', returns None if not found.
If 'name' is not specified, it returns a list of all armatures in the
current scene.


Code: Select all

import Blender

arm = Blender.Armature.Get("Armature")
print dir(arm)

['bones', 'getBones', 'getName', 'name', 'setName']


Code: Select all

import Blender

import Blender

arm = Blender.Armature.Get("Armature")
print  arm.getBones.__doc__

() - return Armature root bones


Code: Select all

import Blender

arm = Blender.Armature.Get("Armature")
bone = arm.getBones()
print bone

[[Bone "Bone"]]


Code: Select all

import Blender

arm = Blender.Armature.Get("Armature")
bone = arm.getBones()[0]
print dir(bone)

['children', 'getChildren', 'getHead', 'getLoc', 'getName', 'getParent', 'getQua
t', 'getRoll', 'getSize', 'getTail', 'hasParent', 'head', 'loc', 'name', 'parent
', 'quat', 'roll', 'setHead', 'setLoc', 'setName', 'setQuat', 'setRoll', 'setSiz
e', 'setTail', 'size', 'tail']


Code: Select all

import Blender

arm = Blender.Armature.Get("Armature")
bone = arm.getBones()[0]
d = dir(bone)
for f in d:
   exec("print \"" + f + ": \"" + " + str(bone." + f + ".__doc__)")

children: list() -> new list
list(sequence) -> new list initialized from sequence's items
getChildren: () - return Bone children list
getHead: () - return Bone head
getLoc: () - return Bone loc
getName: () - return Bone name
getParent: () - return the parent bone of this one if it exists. Otherwise raise
an error. Check this condition with the hasParent() method.
getQuat: () - return Bone quat
getRoll: () - return Bone roll
getSize: () - return Bone size
getTail: () - return Bone tail
hasParent: () - return true if bone has a parent
head: list() -> new list
list(sequence) -> new list initialized from sequence's items
loc: list() -> new list
list(sequence) -> new list initialized from sequence's items
name: str(object) -> string

Return a nice string representation of the object.
If the argument is a string, the return value is the same object.
parent: None
quat: list() -> new list
list(sequence) -> new list initialized from sequence's items
roll: float(x) -> floating point number

Convert a string or number to a floating point number, if possible.
setHead: (float,float,float) - set Bone head pos
setLoc: (float,float,float) - set Bone loc
setName: (str) - rename Bone
setQuat: (float,float,float,float) - set Bone quat
setRoll: (float) - set Bone roll
setSize: (float,float,float) - set Bone size
setTail: (float,float,float) - set Bone tail pos
size: list() -> new list
list(sequence) -> new list initialized from sequence's items
tail: list() -> new list
list(sequence) -> new list initialized from sequence's items


without being a full standalone doc, I think what is already avalaible is helpful enough to get everyone started.

Martin
Life is what happens to you when you're busy making other plans.

- John Lennon

Haunt_House
Posts: 27
Joined: Tue Oct 22, 2002 9:03 am

Postby Haunt_House » Wed Jul 30, 2003 10:00 pm

My apologies

My error could be that I still live in the Python Blender stone ages.

So I searched for a kind of syntax that seems to be more or less gone.

Well, there are areas where I am not that clumsy :wink:

At least now I know it really WAS me.

Thanks Martin.

(you did not sound rude at all to me)


Return to “Python”

Who is online

Users browsing this forum: No registered users and 0 guests