RNA/Py API

change how data is added. eg.
 bpy.data.add_mesh(name) --> bpy.data.meshes.new(name)
 bpy.data.remove_lamp(lamp) --> bpy.data.lamps.remove(lamp)


image and texture stil use add_* funcs
This commit is contained in:
2010-01-09 23:44:01 +00:00
parent 99b713e8b0
commit 08c9ecb3b0
20 changed files with 526 additions and 235 deletions

View File

@@ -447,7 +447,7 @@ def write(filename, objects, scene,
break
if has_quads:
newob = bpy.data.add_object('MESH', 'temp_object')
newob = bpy.data.objects.new('temp_object', 'MESH')
newob.data = me
# if we forget to set Object.data - crash
scene.objects.link(newob)
@@ -468,7 +468,7 @@ def write(filename, objects, scene,
if not (len(face_index_pairs)+len(edges)+len(me.verts)): # Make sure there is somthing to write
# clean up
bpy.data.remove_mesh(me)
bpy.data.meshes.remove(me)
continue # dont bother with this mesh.
@@ -510,24 +510,12 @@ def write(filename, objects, scene,
# XXX update
tface = me.active_uv_texture.data
# exception only raised if Python 2.3 or lower...
try:
face_index_pairs.sort(key = lambda a: (a[0].material_index, tface[a[1]].image, a[0].smooth))
except:
face_index_pairs.sort(lambda a,b: cmp((a[0].material_index, tface[a[1]].image, a[0].smooth),
(b[0].material_index, tface[b[1]].image, b[0].smooth)))
face_index_pairs.sort(key=lambda a: (a[0].material_index, tface[a[1]].image, a[0].smooth))
elif len(materials) > 1:
try:
face_index_pairs.sort(key = lambda a: (a[0].material_index, a[0].smooth))
except:
face_index_pairs.sort(lambda a,b: cmp((a[0].material_index, a[0].smooth),
(b[0].material_index, b[0].smooth)))
face_index_pairs.sort(key = lambda a: (a[0].material_index, a[0].smooth))
else:
# no materials
try:
face_index_pairs.sort(key = lambda a: a[0].smooth)
except:
face_index_pairs.sort(lambda a,b: cmp(a[0].smooth, b[0].smooth))
face_index_pairs.sort(key = lambda a: a[0].smooth)
# if EXPORT_KEEP_VERT_ORDER:
# pass
# elif faceuv:
@@ -609,7 +597,8 @@ def write(filename, objects, scene,
if EXPORT_NORMALS:
for f in faces:
if f.smooth:
for v in f:
for vIdx in f.verts:
v = me.verts[vIdx]
noKey = veckey3d(v.normal)
if noKey not in globalNormals:
globalNormals[noKey] = totno
@@ -779,7 +768,7 @@ def write(filename, objects, scene,
totuvco += uv_unique_count
# clean up
bpy.data.remove_mesh(me)
bpy.data.meshes.remove(me)
if ob_main.dupli_type != 'NONE':
ob_main.free_dupli_list()