2.5 Python api

- rearranged modules bpyui -> bpy.ui, bpy -> bpy.data, remove bpydoc
- new module bpy.types, stores a list of all struct types
- added __rna__ attribute to types - eg bpy.types.World.__rna__ so you can access the rna data from a type. (so bpydoc.structs isnt needed anymore)
- removed unused subtyping method (use python subclassing rather then C PyTypeObject)
This commit is contained in:
2009-03-13 07:50:07 +00:00
parent 432171fd99
commit a4793a3b4a
5 changed files with 129 additions and 234 deletions

View File

@@ -121,12 +121,19 @@ def rna2epy(target_path):
try: return rna_struct.base.identifier
except: return '' # invalid id
#structs = [(base_id(rna_struct), rna_struct.identifier, rna_struct) for rna_struct in bpydoc.structs.values()]
#structs = [(base_id(rna_struct), rna_struct.identifier, rna_struct) for rna_struct in bpy.doc.structs.values()]
'''
structs = []
for rna_struct in bpydoc.structs.values():
for rna_struct in bpy.doc.structs.values():
structs.append( (base_id(rna_struct), rna_struct.identifier, rna_struct) )
'''
structs = []
for rna_type_name in dir(bpy.types):
rna_type = getattr(bpy.types, rna_type_name)
if hasattr(rna_type, '__rna__'):
rna_struct = rna_type.__rna__
structs.append( (base_id(rna_struct), rna_struct.identifier, rna_struct) )
structs.sort() # not needed but speeds up sort below, setting items without an inheritance first
@@ -178,7 +185,7 @@ def rna2epy(target_path):
def op2epy(target_path):
out = open(target_path, 'w')
operators = dir(bpyoperator)
operators = dir(bpy.ops)
operators.remove('add')
operators.remove('remove')
operators.sort()
@@ -193,7 +200,7 @@ def op2epy(target_path):
kw_args = [] # "foo = 1", "bar=0.5", "spam='ENUM'"
kw_arg_attrs = [] # "@type mode: int"
rna = getattr(bpyoperator, op).rna
rna = getattr(bpy.ops, op).rna
rna_struct = rna.rna_type
# print (dir(rna))
# print (dir(rna_struct))