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:
@@ -537,7 +537,7 @@ def write_pov(filename, scene=None, info_callback=None):
|
||||
writeMatrix(matrix)
|
||||
file.write('}\n')
|
||||
|
||||
bpy.data.remove_mesh(me)
|
||||
bpy.data.meshes.remove(me)
|
||||
|
||||
def exportWorld(world):
|
||||
if not world:
|
||||
|
||||
@@ -1061,7 +1061,7 @@ def save_3ds(filename, context):
|
||||
kfdata.add_subchunk(make_kf_obj_node(ob, name_to_id))
|
||||
'''
|
||||
# if not blender_mesh.users:
|
||||
bpy.data.remove_mesh(blender_mesh)
|
||||
bpy.data.meshes.remove(blender_mesh)
|
||||
# blender_mesh.verts = None
|
||||
|
||||
i+=i
|
||||
|
||||
@@ -2989,7 +2989,7 @@ Takes: {''')
|
||||
|
||||
# Clear mesh data Only when writing with modifiers applied
|
||||
for me in meshes_to_clear:
|
||||
bpy.data.remove_mesh(me)
|
||||
bpy.data.meshes.remove(me)
|
||||
# me.verts = None
|
||||
|
||||
# --------------------------- Footer
|
||||
@@ -3391,8 +3391,7 @@ class ExportFBX(bpy.types.Operator):
|
||||
|
||||
|
||||
def poll(self, context):
|
||||
print("Poll")
|
||||
return context.active_object != None
|
||||
return context.active_object
|
||||
|
||||
def execute(self, context):
|
||||
if not self.properties.path:
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -254,7 +254,7 @@ def write(filename, scene, ob, \
|
||||
print("writing", filename, "done")
|
||||
|
||||
if EXPORT_APPLY_MODIFIERS:
|
||||
bpy.data.remove_mesh(mesh)
|
||||
bpy.data.meshes.remove(mesh)
|
||||
|
||||
# XXX
|
||||
"""
|
||||
|
||||
@@ -879,7 +879,7 @@ class x3d_class:
|
||||
|
||||
# free mesh created with create_mesh()
|
||||
if me != ob.data:
|
||||
bpy.data.remove_mesh(me)
|
||||
bpy.data.meshes.remove(me)
|
||||
|
||||
elif objType == "LAMP":
|
||||
# elif objType == "Lamp":
|
||||
|
||||
@@ -410,8 +410,7 @@ def process_next_chunk(file, previous_chunk, importedObjects, IMAGE_SEARCH):
|
||||
myVertMapping = dict( [ (ii, i) for i, ii in enumerate(vertsToUse) ] )
|
||||
|
||||
tempName= '%s_%s' % (contextObName, matName) # matName may be None.
|
||||
bmesh = bpy.data.add_mesh(tempName)
|
||||
# bmesh = bpy.data.meshes.new(tempName)
|
||||
bmesh = bpy.data.meshes.new(tempName)
|
||||
|
||||
if matName == None:
|
||||
img = None
|
||||
@@ -465,7 +464,7 @@ def process_next_chunk(file, previous_chunk, importedObjects, IMAGE_SEARCH):
|
||||
# targetFace.image = img
|
||||
|
||||
# bmesh.transform(contextMatrix)
|
||||
ob = bpy.data.add_object("MESH", tempName)
|
||||
ob = bpy.data.objects.new(tempName, 'MESH')
|
||||
ob.data = bmesh
|
||||
SCN.objects.link(ob)
|
||||
# ob = SCN_OBJECTS.new(bmesh, tempName)
|
||||
@@ -766,8 +765,8 @@ def process_next_chunk(file, previous_chunk, importedObjects, IMAGE_SEARCH):
|
||||
x,y,z = struct.unpack('<3f', temp_data)
|
||||
new_chunk.bytes_read += STRUCT_SIZE_3FLOAT
|
||||
|
||||
ob = bpy.data.add_object("LAMP", "Lamp")
|
||||
ob.data = bpy.data.add_lamp("Lamp")
|
||||
ob = bpy.data.objects.new("Lamp", 'LAMP')
|
||||
ob.data = bpy.data.lamps.new("Lamp")
|
||||
SCN.objects.link(ob)
|
||||
|
||||
contextLamp[1]= ob.data
|
||||
|
||||
@@ -712,8 +712,7 @@ def create_mesh(scn, new_objects, has_ngons, CREATE_FGONS, CREATE_EDGES, verts_l
|
||||
for name, index in list(material_mapping.items()):
|
||||
materials[index]= unique_materials[name]
|
||||
|
||||
me= bpy.data.add_mesh(dataname)
|
||||
# me= bpy.data.meshes.new(dataname)
|
||||
me= bpy.data.meshes.new(dataname)
|
||||
|
||||
# make sure the list isnt too big
|
||||
for material in materials[0:16]:
|
||||
@@ -864,7 +863,7 @@ def create_mesh(scn, new_objects, has_ngons, CREATE_FGONS, CREATE_EDGES, verts_l
|
||||
me.update()
|
||||
# me.calcNormals()
|
||||
|
||||
ob= bpy.data.add_object("MESH", "Mesh")
|
||||
ob= bpy.data.objects.new("Mesh", 'MESH')
|
||||
ob.data= me
|
||||
scn.objects.link(ob)
|
||||
# ob= scn.objects.new(me)
|
||||
|
||||
@@ -318,7 +318,22 @@ def connect_splines(splines):
|
||||
else:
|
||||
return b, a
|
||||
|
||||
def test_join(p1a, p1b, p2a, p2b, length_average):
|
||||
#def test_join(p1a, p1b, p2a, p2b, length_average):
|
||||
def test_join(s1, s2, dir1, dir2, length_average):
|
||||
if dir1 is False:
|
||||
p1a = s1.points[0]
|
||||
p1b = s1.points[1]
|
||||
else:
|
||||
p1a = s1.points[-1]
|
||||
p1b = s1.points[-2]
|
||||
|
||||
if dir2 is False:
|
||||
p2a = s2.points[0]
|
||||
p2b = s2.points[1]
|
||||
else:
|
||||
p2a = s2.points[-1]
|
||||
p2b = s2.points[-2]
|
||||
|
||||
# compare length between tips
|
||||
if (p1a - p2a).length > (length_average / EPS_SPLINE_DIV):
|
||||
return False
|
||||
@@ -346,7 +361,7 @@ def connect_splines(splines):
|
||||
if s1 is s2:
|
||||
continue
|
||||
|
||||
length_average = (s1.length + s2.length) / 2.0
|
||||
length_average = min(s1.length, s2.length)
|
||||
|
||||
key2a = s2.points[0].toTuple(HASH_PREC)
|
||||
key2b = s2.points[-1].toTuple(HASH_PREC)
|
||||
@@ -355,8 +370,7 @@ def connect_splines(splines):
|
||||
key_pair = sort_pair(key1a, key2a)
|
||||
if key_pair not in comparisons:
|
||||
comparisons.add(key_pair)
|
||||
if test_join(s1.points[0], s1.points[1], s2.points[0], s2.points[1], length_average) or \
|
||||
test_join(s1.points[1], s1.points[2], s2.points[1], s2.points[2], length_average):
|
||||
if test_join(s1, s2, False, False, length_average):
|
||||
s1.points[:0] = reversed(s2.points)
|
||||
s1.bb += s2.bb
|
||||
s1.calc_length()
|
||||
@@ -367,8 +381,7 @@ def connect_splines(splines):
|
||||
key_pair = sort_pair(key1a, key2b)
|
||||
if key_pair not in comparisons:
|
||||
comparisons.add(key_pair)
|
||||
if test_join(s1.points[0], s1.points[1], s2.points[-1], s2.points[-2], length_average) or \
|
||||
test_join(s1.points[1], s1.points[2], s2.points[-2], s2.points[-3], length_average):
|
||||
if test_join(s1, s2, False, True, length_average):
|
||||
s1.points[:0] = s2.points
|
||||
s1.bb += s2.bb
|
||||
s1.calc_length()
|
||||
@@ -379,8 +392,7 @@ def connect_splines(splines):
|
||||
key_pair = sort_pair(key1b, key2b)
|
||||
if key_pair not in comparisons:
|
||||
comparisons.add(key_pair)
|
||||
if test_join(s1.points[-1], s1.points[-2], s2.points[-1], s2.points[-2], length_average) or \
|
||||
test_join(s1.points[-2], s1.points[-3], s2.points[-2], s2.points[-3], length_average):
|
||||
if test_join(s1, s2, True, True, length_average):
|
||||
s1.points += list(reversed(s2.points))
|
||||
s1.bb += s2.bb
|
||||
s1.calc_length()
|
||||
@@ -388,11 +400,10 @@ def connect_splines(splines):
|
||||
do_join = True
|
||||
break
|
||||
|
||||
key_pair = sort_pair(key1a, key2a)
|
||||
key_pair = sort_pair(key1b, key2a)
|
||||
if key_pair not in comparisons:
|
||||
comparisons.add(key_pair)
|
||||
if test_join(s1.points[-1], s1.points[-2], s2.points[0], s2.points[1], length_average) or \
|
||||
test_join(s1.points[-2], s1.points[-3], s2.points[1], s2.points[2], length_average):
|
||||
if test_join(s1, s2, True, False, length_average):
|
||||
s1.points += s2.points
|
||||
s1.bb += s2.bb
|
||||
s1.calc_length()
|
||||
@@ -457,12 +468,12 @@ def calculate(gp):
|
||||
# remove double faces
|
||||
faces = dict([(tuple(sorted(f)), f) for f in faces]).values()
|
||||
|
||||
mesh = bpy.data.add_mesh("Retopo")
|
||||
mesh = bpy.data.meshes.new("Retopo")
|
||||
mesh.from_pydata(verts, [], faces)
|
||||
|
||||
scene = bpy.context.scene
|
||||
mesh.update()
|
||||
obj_new = bpy.data.add_object('MESH', "Torus")
|
||||
obj_new = bpy.data.objects.new("Torus", 'MESH')
|
||||
obj_new.data = mesh
|
||||
scene.objects.link(obj_new)
|
||||
|
||||
|
||||
@@ -380,8 +380,8 @@ def generate_test(context, metarig_type="", GENERATE_FINAL=True):
|
||||
scene = context.scene
|
||||
|
||||
def create_empty_armature(name):
|
||||
obj_new = bpy.data.add_object('ARMATURE', name)
|
||||
armature = bpy.data.add_armature(name)
|
||||
obj_new = bpy.data.objects.new(name, 'ARMATURE')
|
||||
armature = bpy.data.armatures.new(name)
|
||||
obj_new.data = armature
|
||||
scene.objects.link(obj_new)
|
||||
scene.objects.active = obj_new
|
||||
|
||||
@@ -101,7 +101,7 @@ class AddTorus(bpy.types.Operator):
|
||||
self.properties.major_segments,
|
||||
self.properties.minor_segments)
|
||||
|
||||
mesh = bpy.data.add_mesh("Torus")
|
||||
mesh = bpy.data.meshes.new("Torus")
|
||||
|
||||
mesh.add_geometry(int(len(verts_loc) / 3), 0, int(len(faces) / 4))
|
||||
mesh.verts.foreach_set("co", verts_loc)
|
||||
@@ -114,7 +114,7 @@ class AddTorus(bpy.types.Operator):
|
||||
ob.selected = False
|
||||
|
||||
mesh.update()
|
||||
ob_new = bpy.data.add_object('MESH', "Torus")
|
||||
ob_new = bpy.data.objects.new("Torus", 'MESH')
|
||||
ob_new.data = mesh
|
||||
scene.objects.link(ob_new)
|
||||
scene.objects.active = ob_new
|
||||
|
||||
@@ -145,6 +145,7 @@ class Retopo(bpy.types.Operator):
|
||||
|
||||
def execute(self, context):
|
||||
import retopo
|
||||
reload(retopo)
|
||||
retopo.main()
|
||||
return {'FINISHED'}
|
||||
|
||||
|
||||
@@ -60,10 +60,7 @@ class NLA_MT_view(bpy.types.Menu):
|
||||
layout.separator()
|
||||
layout.prop(st, "show_cframe_indicator")
|
||||
|
||||
if st.show_seconds:
|
||||
layout.operator("anim.time_toggle", text="Show Frames")
|
||||
else:
|
||||
layout.operator("anim.time_toggle", text="Show Seconds")
|
||||
layout.operator("anim.time_toggle", text="Show Frames" if st.show_seconds else "Show Seconds")
|
||||
|
||||
layout.prop(st, "show_strip_curves")
|
||||
|
||||
|
||||
@@ -803,8 +803,7 @@ class VIEW3D_PT_tools_weightpaint_options(View3DPanel):
|
||||
col.prop(wpaint, "normals")
|
||||
col.prop(wpaint, "spray")
|
||||
|
||||
data = context.weight_paint_object.data
|
||||
if type(data) == bpy.types.Mesh:
|
||||
if context.weight_paint_object.type == 'MESH':
|
||||
col.prop(data, "use_mirror_x")
|
||||
|
||||
# Commented out because the Apply button isn't an operator yet, making these settings useless
|
||||
|
||||
@@ -1599,7 +1599,7 @@ static void do_picker_rna_cb(bContext *C, void *bt1, void *unused)
|
||||
PointerRNA ptr = but->rnapoin;
|
||||
float rgb[4];
|
||||
|
||||
if (&ptr && prop) {
|
||||
if (prop) {
|
||||
RNA_property_float_get_array(&ptr, prop, rgb);
|
||||
ui_update_block_buts_rgb(but->block, rgb);
|
||||
}
|
||||
|
||||
@@ -231,6 +231,33 @@ void RNA_api_text(struct StructRNA *srna);
|
||||
void RNA_api_ui_layout(struct StructRNA *srna);
|
||||
void RNA_api_wm(struct StructRNA *srna);
|
||||
|
||||
/* main collection functions */
|
||||
void RNA_def_main_cameras(BlenderRNA *brna, PropertyRNA *cprop);
|
||||
void RNA_def_main_scenes(BlenderRNA *brna, PropertyRNA *cprop);
|
||||
void RNA_def_main_objects(BlenderRNA *brna, PropertyRNA *cprop);
|
||||
void RNA_def_main_materials(BlenderRNA *brna, PropertyRNA *cprop);
|
||||
void RNA_def_main_node_groups(BlenderRNA *brna, PropertyRNA *cprop);
|
||||
void RNA_def_main_meshes(BlenderRNA *brna, PropertyRNA *cprop);
|
||||
void RNA_def_main_lamps(BlenderRNA *brna, PropertyRNA *cprop);
|
||||
void RNA_def_main_libraries(BlenderRNA *brna, PropertyRNA *cprop);
|
||||
void RNA_def_main_screens(BlenderRNA *brna, PropertyRNA *cprop);
|
||||
void RNA_def_main_window_managers(BlenderRNA *brna, PropertyRNA *cprop);
|
||||
void RNA_def_main_images(BlenderRNA *brna, PropertyRNA *cprop);
|
||||
void RNA_def_main_lattices(BlenderRNA *brna, PropertyRNA *cprop);
|
||||
void RNA_def_main_curves(BlenderRNA *brna, PropertyRNA *cprop);
|
||||
void RNA_def_main_metaballs(BlenderRNA *brna, PropertyRNA *cprop);
|
||||
void RNA_def_main_vfonts(BlenderRNA *brna, PropertyRNA *cprop);
|
||||
void RNA_def_main_textures(BlenderRNA *brna, PropertyRNA *cprop);
|
||||
void RNA_def_main_brushes(BlenderRNA *brna, PropertyRNA *cprop);
|
||||
void RNA_def_main_worlds(BlenderRNA *brna, PropertyRNA *cprop);
|
||||
void RNA_def_main_groups(BlenderRNA *brna, PropertyRNA *cprop);
|
||||
void RNA_def_main_texts(BlenderRNA *brna, PropertyRNA *cprop);
|
||||
void RNA_def_main_sounds(BlenderRNA *brna, PropertyRNA *cprop);
|
||||
void RNA_def_main_armatures(BlenderRNA *brna, PropertyRNA *cprop);
|
||||
void RNA_def_main_actions(BlenderRNA *brna, PropertyRNA *cprop);
|
||||
void RNA_def_main_particles(BlenderRNA *brna, PropertyRNA *cprop);
|
||||
void RNA_def_main_gpencil(BlenderRNA *brna, PropertyRNA *cprop);
|
||||
|
||||
/* ID Properties */
|
||||
|
||||
extern StringPropertyRNA rna_IDProperty_string;
|
||||
|
||||
@@ -235,40 +235,44 @@ static PointerRNA rna_Test_test_get(PointerRNA *ptr)
|
||||
|
||||
#else
|
||||
|
||||
typedef void (*CollectionDefFunc)(struct BlenderRNA *brna, struct PropertyRNA *cprop);
|
||||
|
||||
void RNA_def_main(BlenderRNA *brna)
|
||||
{
|
||||
StructRNA *srna;
|
||||
PropertyRNA *prop;
|
||||
CollectionDefFunc func;
|
||||
|
||||
const char *lists[][6]= {
|
||||
{"cameras", "Camera", "rna_Main_camera_begin", "Cameras", "Camera datablocks.", (char *)RNA_def_main_cameras},
|
||||
{"scenes", "Scene", "rna_Main_scene_begin", "Scenes", "Scene datablocks.", (char *)RNA_def_main_scenes},
|
||||
{"objects", "Object", "rna_Main_object_begin", "Objects", "Object datablocks.", (char *)RNA_def_main_objects},
|
||||
{"materials", "Material", "rna_Main_mat_begin", "Materials", "Material datablocks.", (char *)RNA_def_main_materials},
|
||||
{"node_groups", "NodeTree", "rna_Main_nodetree_begin", "Node Groups", "Node group datablocks.", (char *)RNA_def_main_node_groups},
|
||||
{"meshes", "Mesh", "rna_Main_mesh_begin", "Meshes", "Mesh datablocks.", (char *)RNA_def_main_meshes},
|
||||
{"lamps", "Lamp", "rna_Main_lamp_begin", "Lamps", "Lamp datablocks.", (char *)RNA_def_main_lamps},
|
||||
{"libraries", "Library", "rna_Main_library_begin", "Libraries", "Library datablocks.", (char *)RNA_def_main_libraries},
|
||||
{"screens", "Screen", "rna_Main_screen_begin", "Screens", "Screen datablocks.", (char *)RNA_def_main_screens},
|
||||
{"window_managers", "WindowManager", "rna_Main_wm_begin", "Window Managers", "Window manager datablocks.", (char *)RNA_def_main_window_managers},
|
||||
{"images", "Image", "rna_Main_image_begin", "Images", "Image datablocks.", (char *)RNA_def_main_images},
|
||||
{"lattices", "Lattice", "rna_Main_latt_begin", "Lattices", "Lattice datablocks.", (char *)RNA_def_main_lattices},
|
||||
{"curves", "Curve", "rna_Main_curve_begin", "Curves", "Curve datablocks.", (char *)RNA_def_main_curves} ,
|
||||
{"metaballs", "MetaBall", "rna_Main_mball_begin", "Metaballs", "Metaball datablocks.", (char *)RNA_def_main_metaballs},
|
||||
{"vfonts", "VectorFont", "rna_Main_vfont_begin", "Vector Fonts", "Vector font datablocks.", (char *)RNA_def_main_vfonts},
|
||||
{"textures", "Texture", "rna_Main_tex_begin", "Textures", "Texture datablocks.", (char *)RNA_def_main_textures},
|
||||
{"brushes", "Brush", "rna_Main_brush_begin", "Brushes", "Brush datablocks.", (char *)RNA_def_main_brushes},
|
||||
{"worlds", "World", "rna_Main_world_begin", "Worlds", "World datablocks.", (char *)RNA_def_main_worlds},
|
||||
{"groups", "Group", "rna_Main_group_begin", "Groups", "Group datablocks.", (char *)RNA_def_main_groups},
|
||||
/* {"keys", "Key", "rna_Main_key_begin", "Keys", "Key datablocks.", NULL}, */
|
||||
{"scripts", "ID", "rna_Main_script_begin", "Scripts", "Script datablocks (DEPRECATED).", (char *)NULL},
|
||||
{"texts", "Text", "rna_Main_text_begin", "Texts", "Text datablocks.", (char *)RNA_def_main_texts},
|
||||
{"sounds", "Sound", "rna_Main_sound_begin", "Sounds", "Sound datablocks.", (char *)RNA_def_main_sounds},
|
||||
{"armatures", "Armature", "rna_Main_armature_begin", "Armatures", "Armature datablocks.", (char *)RNA_def_main_armatures},
|
||||
{"actions", "Action", "rna_Main_action_begin", "Actions", "Action datablocks.", (char *)RNA_def_main_actions},
|
||||
{"particles", "ParticleSettings", "rna_Main_particle_begin", "Particles", "Particle datablocks.", (char *)RNA_def_main_particles},
|
||||
{"gpencil", "GreasePencil", "rna_Main_gpencil_begin", "Grease Pencil", "Grease Pencil datablocks.", (char *)RNA_def_main_gpencil},
|
||||
{NULL, NULL, NULL, NULL, NULL, NULL}};
|
||||
|
||||
const char *lists[][5]= {
|
||||
{"cameras", "Camera", "rna_Main_camera_begin", "Cameras", "Camera datablocks."},
|
||||
{"scenes", "Scene", "rna_Main_scene_begin", "Scenes", "Scene datablocks."},
|
||||
{"objects", "Object", "rna_Main_object_begin", "Objects", "Object datablocks."},
|
||||
{"materials", "Material", "rna_Main_mat_begin", "Materials", "Material datablocks."},
|
||||
{"nodegroups", "NodeTree", "rna_Main_nodetree_begin", "Node Groups", "Node group datablocks."},
|
||||
{"meshes", "Mesh", "rna_Main_mesh_begin", "Meshes", "Mesh datablocks."}, // "add_mesh", "remove_mesh"
|
||||
{"lamps", "Lamp", "rna_Main_lamp_begin", "Lamps", "Lamp datablocks."},
|
||||
{"libraries", "Library", "rna_Main_library_begin", "Libraries", "Library datablocks."},
|
||||
{"screens", "Screen", "rna_Main_screen_begin", "Screens", "Screen datablocks."},
|
||||
{"windowmanagers", "WindowManager", "rna_Main_wm_begin", "Window Managers", "Window manager datablocks."},
|
||||
{"images", "Image", "rna_Main_image_begin", "Images", "Image datablocks."},
|
||||
{"lattices", "Lattice", "rna_Main_latt_begin", "Lattices", "Lattice datablocks."},
|
||||
{"curves", "Curve", "rna_Main_curve_begin", "Curves", "Curve datablocks."} ,
|
||||
{"metaballs", "MetaBall", "rna_Main_mball_begin", "Metaballs", "Metaball datablocks."},
|
||||
{"vfonts", "VectorFont", "rna_Main_vfont_begin", "Vector Fonts", "Vector font datablocks."},
|
||||
{"textures", "Texture", "rna_Main_tex_begin", "Textures", "Texture datablocks."},
|
||||
{"brushes", "Brush", "rna_Main_brush_begin", "Brushes", "Brush datablocks."},
|
||||
{"worlds", "World", "rna_Main_world_begin", "Worlds", "World datablocks."},
|
||||
{"groups", "Group", "rna_Main_group_begin", "Groups", "Group datablocks."},
|
||||
/* {"keys", "Key", "rna_Main_key_begin", "Keys", "Key datablocks."}, */
|
||||
{"scripts", "ID", "rna_Main_script_begin", "Scripts", "Script datablocks (DEPRECATED)."},
|
||||
{"texts", "Text", "rna_Main_text_begin", "Texts", "Text datablocks."},
|
||||
{"sounds", "Sound", "rna_Main_sound_begin", "Sounds", "Sound datablocks."},
|
||||
{"armatures", "Armature", "rna_Main_armature_begin", "Armatures", "Armature datablocks."},
|
||||
{"actions", "Action", "rna_Main_action_begin", "Actions", "Action datablocks."},
|
||||
{"particles", "ParticleSettings", "rna_Main_particle_begin", "Particles", "Particle datablocks."},
|
||||
{"gpencil", "GreasePencil", "rna_Main_gpencil_begin", "Grease Pencil", "Grease Pencil datablocks."},
|
||||
{NULL, NULL, NULL, NULL, NULL}};
|
||||
int i;
|
||||
|
||||
srna= RNA_def_struct(brna, "Main", NULL);
|
||||
@@ -287,6 +291,11 @@ void RNA_def_main(BlenderRNA *brna)
|
||||
RNA_def_property_struct_type(prop, lists[i][1]);
|
||||
RNA_def_property_collection_funcs(prop, lists[i][2], "rna_iterator_listbase_next", "rna_iterator_listbase_end", "rna_iterator_listbase_get", 0, 0, 0);
|
||||
RNA_def_property_ui_text(prop, lists[i][3], lists[i][4]);
|
||||
|
||||
/* collection functions */
|
||||
func= (CollectionDefFunc *)lists[i][5];
|
||||
if(func)
|
||||
func(brna, prop);
|
||||
}
|
||||
|
||||
RNA_api_main(srna);
|
||||
|
||||
@@ -43,110 +43,145 @@
|
||||
#include "BKE_material.h"
|
||||
#include "BKE_image.h"
|
||||
#include "BKE_texture.h"
|
||||
#include "BKE_scene.h"
|
||||
|
||||
#include "DNA_armature_types.h"
|
||||
#include "DNA_camera_types.h"
|
||||
#include "DNA_lamp_types.h"
|
||||
#include "DNA_material_types.h"
|
||||
#include "DNA_mesh_types.h"
|
||||
#include "DNA_object_types.h"
|
||||
|
||||
static Mesh *rna_Main_add_mesh(Main *bmain, char *name)
|
||||
{
|
||||
Mesh *me= add_mesh(name);
|
||||
me->id.us--;
|
||||
return me;
|
||||
}
|
||||
|
||||
static void rna_Main_remove_mesh(Main *bmain, ReportList *reports, Mesh *me)
|
||||
{
|
||||
if(me->id.us == 0)
|
||||
free_libblock(&bmain->mesh, me);
|
||||
else
|
||||
BKE_report(reports, RPT_ERROR, "Mesh must have zero users to be removed.");
|
||||
|
||||
/* XXX python now has invalid pointer? */
|
||||
}
|
||||
|
||||
static void rna_Main_remove_armature(Main *bmain, ReportList *reports, bArmature *arm)
|
||||
{
|
||||
if(arm->id.us == 0)
|
||||
free_libblock(&bmain->armature, arm);
|
||||
else
|
||||
BKE_report(reports, RPT_ERROR, "Armature must have zero users to be removed.");
|
||||
|
||||
/* XXX python now has invalid pointer? */
|
||||
}
|
||||
|
||||
static bArmature *rna_Main_add_armature(Main *bmain, char *name)
|
||||
{
|
||||
bArmature *arm= add_armature(name);
|
||||
arm->id.us--;
|
||||
return arm;
|
||||
}
|
||||
|
||||
static Lamp *rna_Main_add_lamp(Main *bmain, char *name)
|
||||
{
|
||||
Lamp *la= add_lamp(name);
|
||||
la->id.us--;
|
||||
return la;
|
||||
}
|
||||
|
||||
/*
|
||||
static void rna_Main_remove_lamp(Main *bmain, ReportList *reports, Lamp *la)
|
||||
{
|
||||
if(la->id.us == 0)
|
||||
free_libblock(&main->lamp, la);
|
||||
else
|
||||
BKE_report(reports, RPT_ERROR, "Lamp must have zero users to be removed.");
|
||||
}
|
||||
*/
|
||||
|
||||
static Object* rna_Main_add_object(Main *bmain, int type, char *name)
|
||||
{
|
||||
Object *ob= add_only_object(type, name);
|
||||
ob->id.us--;
|
||||
return ob;
|
||||
}
|
||||
|
||||
/*
|
||||
NOTE: the following example shows when this function should _not_ be called
|
||||
|
||||
ob = bpy.data.add_object()
|
||||
scene.add_object(ob)
|
||||
|
||||
# ob is freed here
|
||||
scene.remove_object(ob)
|
||||
|
||||
# don't do this since ob is already freed!
|
||||
bpy.data.remove_object(ob)
|
||||
*/
|
||||
static void rna_Main_remove_object(Main *bmain, ReportList *reports, Object *ob)
|
||||
{
|
||||
if(ob->id.us == 0)
|
||||
free_libblock(&bmain->object, ob);
|
||||
else
|
||||
BKE_report(reports, RPT_ERROR, "Object must have zero users to be removed.");
|
||||
}
|
||||
|
||||
static Material *rna_Main_add_material(Main *bmain, char *name)
|
||||
{
|
||||
return add_material(name);
|
||||
}
|
||||
|
||||
/* TODO: remove material? */
|
||||
|
||||
struct Tex *rna_Main_add_texture(Main *bmain, char *name)
|
||||
static Tex *rna_Main_add_texture(Main *bmain, char *name)
|
||||
{
|
||||
return add_texture(name);
|
||||
}
|
||||
|
||||
/* TODO: remove texture? */
|
||||
|
||||
struct Image *rna_Main_add_image(Main *bmain, char *filename)
|
||||
static Image *rna_Main_add_image(Main *bmain, char *filename)
|
||||
{
|
||||
return BKE_add_image_file(filename, 0);
|
||||
}
|
||||
|
||||
static Camera *rna_Main_cameras_new(bContext *C, char* name)
|
||||
{
|
||||
return add_camera(name);
|
||||
}
|
||||
static void rna_Main_cameras_remove(bContext *C, ReportList *reports, struct Camera *camera)
|
||||
{
|
||||
Main *bmain= CTX_data_main(C);
|
||||
if(camera->id.us == 0)
|
||||
free_libblock(&bmain->camera, camera);
|
||||
else
|
||||
BKE_reportf(reports, RPT_ERROR, "Camera \"%s\" must have zero users to be removed, found %d.", camera->id.name+2, camera->id.us);
|
||||
|
||||
/* XXX python now has invalid pointer? */
|
||||
}
|
||||
|
||||
static Scene *rna_Main_scenes_new(bContext *C, char* name)
|
||||
{
|
||||
return add_scene(name);
|
||||
}
|
||||
static void rna_Main_scenes_remove(bContext *C, ReportList *reports, struct Scene *scene)
|
||||
{
|
||||
Main *bmain= CTX_data_main(C);
|
||||
free_libblock(&bmain->scene, scene);
|
||||
}
|
||||
|
||||
static Object *rna_Main_objects_new(bContext *C, char* name, int type)
|
||||
{
|
||||
Object *ob= add_only_object(type, name);
|
||||
ob->id.us--;
|
||||
return ob;
|
||||
}
|
||||
static void rna_Main_objects_remove(bContext *C, ReportList *reports, struct Object *object)
|
||||
{
|
||||
/*
|
||||
NOTE: the following example shows when this function should _not_ be called
|
||||
|
||||
ob = bpy.data.add_object()
|
||||
scene.add_object(ob)
|
||||
|
||||
# ob is freed here
|
||||
scene.remove_object(ob)
|
||||
|
||||
# don't do this since ob is already freed!
|
||||
bpy.data.remove_object(ob)
|
||||
*/
|
||||
Main *bmain= CTX_data_main(C);
|
||||
if(object->id.us == 0)
|
||||
free_libblock(&bmain->object, object);
|
||||
else
|
||||
BKE_reportf(reports, RPT_ERROR, "Object \"%s\" must have zero users to be removed, found %d.", object->id.name+2, object->id.us);
|
||||
}
|
||||
|
||||
static Material *rna_Main_materials_new(bContext *C, char* name)
|
||||
{
|
||||
return add_material(name);
|
||||
}
|
||||
static void rna_Main_materials_remove(bContext *C, ReportList *reports, struct Material *material)
|
||||
{
|
||||
Main *bmain= CTX_data_main(C);
|
||||
if(material->id.us == 0)
|
||||
free_libblock(&bmain->mat, material);
|
||||
else
|
||||
BKE_reportf(reports, RPT_ERROR, "Material \"%s\" must have zero users to be removed, found %d.", material->id.name+2, material->id.us);
|
||||
|
||||
/* XXX python now has invalid pointer? */
|
||||
}
|
||||
|
||||
static Mesh *rna_Main_meshes_new(bContext *C, char* name)
|
||||
{
|
||||
Mesh *me= add_mesh(name);
|
||||
me->id.us--;
|
||||
return me;
|
||||
}
|
||||
static void rna_Main_meshes_remove(bContext *C, ReportList *reports, Mesh *mesh)
|
||||
{
|
||||
Main *bmain= CTX_data_main(C);
|
||||
if(mesh->id.us == 0)
|
||||
free_libblock(&bmain->mesh, mesh);
|
||||
else
|
||||
BKE_reportf(reports, RPT_ERROR, "Mesh \"%s\" must have zero users to be removed, found %d.", mesh->id.name+2, mesh->id.us);
|
||||
|
||||
/* XXX python now has invalid pointer? */
|
||||
}
|
||||
|
||||
static Lamp *rna_Main_lamps_new(bContext *C, char* name)
|
||||
{
|
||||
Lamp *lamp= add_lamp(name);
|
||||
lamp->id.us--;
|
||||
return lamp;
|
||||
}
|
||||
static void rna_Main_lamps_remove(bContext *C, ReportList *reports, Lamp *lamp)
|
||||
{
|
||||
Main *bmain= CTX_data_main(C);
|
||||
if(lamp->id.us == 0)
|
||||
free_libblock(&bmain->lamp, lamp);
|
||||
else
|
||||
BKE_reportf(reports, RPT_ERROR, "Lamp \"%s\" must have zero users to be removed, found %d.", lamp->id.name+2, lamp->id.us);
|
||||
|
||||
/* XXX python now has invalid pointer? */
|
||||
}
|
||||
|
||||
static bArmature *rna_Main_armatures_new(bContext *C, char* name)
|
||||
{
|
||||
bArmature *arm= add_armature(name);
|
||||
arm->id.us--;
|
||||
return arm;
|
||||
}
|
||||
static void rna_Main_armatures_remove(bContext *C, ReportList *reports, bArmature *arm)
|
||||
{
|
||||
Main *bmain= CTX_data_main(C);
|
||||
if(arm->id.us == 0)
|
||||
free_libblock(&bmain->armature, arm);
|
||||
else
|
||||
BKE_reportf(reports, RPT_ERROR, "Armature \"%s\" must have zero users to be removed, found %d.", arm->id.name+2, arm->id.us);
|
||||
|
||||
/* XXX python now has invalid pointer? */
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void RNA_api_main(StructRNA *srna)
|
||||
@@ -154,60 +189,6 @@ void RNA_api_main(StructRNA *srna)
|
||||
FunctionRNA *func;
|
||||
PropertyRNA *parm;
|
||||
|
||||
func= RNA_def_function(srna, "add_object", "rna_Main_add_object");
|
||||
RNA_def_function_ui_description(func, "Add a new object.");
|
||||
parm= RNA_def_enum(func, "type", object_type_items, 0, "", "Type of Object.");
|
||||
RNA_def_property_flag(parm, PROP_REQUIRED);
|
||||
parm= RNA_def_string(func, "name", "Object", 0, "", "New name for the datablock.");
|
||||
RNA_def_property_flag(parm, PROP_REQUIRED);
|
||||
parm= RNA_def_pointer(func, "object", "Object", "", "New object.");
|
||||
RNA_def_function_return(func, parm);
|
||||
|
||||
func= RNA_def_function(srna, "remove_object", "rna_Main_remove_object");
|
||||
RNA_def_function_flag(func, FUNC_USE_REPORTS);
|
||||
RNA_def_function_ui_description(func, "Remove an object if it has zero users.");
|
||||
parm= RNA_def_pointer(func, "object", "Object", "", "Object to remove.");
|
||||
RNA_def_property_flag(parm, PROP_REQUIRED);
|
||||
|
||||
func= RNA_def_function(srna, "add_mesh", "rna_Main_add_mesh");
|
||||
RNA_def_function_ui_description(func, "Add a new mesh.");
|
||||
parm= RNA_def_string(func, "name", "Mesh", 0, "", "New name for the datablock.");
|
||||
RNA_def_property_flag(parm, PROP_REQUIRED);
|
||||
parm= RNA_def_pointer(func, "mesh", "Mesh", "", "New mesh.");
|
||||
RNA_def_function_return(func, parm);
|
||||
|
||||
func= RNA_def_function(srna, "remove_mesh", "rna_Main_remove_mesh");
|
||||
RNA_def_function_flag(func, FUNC_USE_REPORTS);
|
||||
RNA_def_function_ui_description(func, "Remove a mesh if it has zero users.");
|
||||
parm= RNA_def_pointer(func, "mesh", "Mesh", "", "Mesh to remove.");
|
||||
RNA_def_property_flag(parm, PROP_REQUIRED);
|
||||
|
||||
func= RNA_def_function(srna, "add_armature", "rna_Main_add_armature");
|
||||
RNA_def_function_ui_description(func, "Add a new armature.");
|
||||
parm= RNA_def_string(func, "name", "Armature", 0, "", "New name for the datablock.");
|
||||
RNA_def_property_flag(parm, PROP_REQUIRED);
|
||||
parm= RNA_def_pointer(func, "armature", "Armature", "", "New armature.");
|
||||
RNA_def_function_return(func, parm);
|
||||
|
||||
func= RNA_def_function(srna, "remove_armature", "rna_Main_remove_armature");
|
||||
RNA_def_function_flag(func, FUNC_USE_REPORTS);
|
||||
RNA_def_function_ui_description(func, "Remove an armature if it has zero users.");
|
||||
parm= RNA_def_pointer(func, "armature", "Armature", "", "Armature to remove.");
|
||||
RNA_def_property_flag(parm, PROP_REQUIRED);
|
||||
|
||||
func= RNA_def_function(srna, "add_lamp", "rna_Main_add_lamp");
|
||||
RNA_def_function_ui_description(func, "Add a new lamp.");
|
||||
parm= RNA_def_string(func, "name", "Lamp", 0, "", "New name for the datablock.");
|
||||
RNA_def_property_flag(parm, PROP_REQUIRED);
|
||||
parm= RNA_def_pointer(func, "mesh", "Lamp", "", "New lamp.");
|
||||
RNA_def_function_return(func, parm);
|
||||
|
||||
func= RNA_def_function(srna, "add_material", "rna_Main_add_material");
|
||||
RNA_def_function_ui_description(func, "Add a new material.");
|
||||
parm= RNA_def_string(func, "name", "Material", 0, "", "New name for the datablock."); /* optional */
|
||||
parm= RNA_def_pointer(func, "material", "Material", "", "New material.");
|
||||
RNA_def_function_return(func, parm);
|
||||
|
||||
func= RNA_def_function(srna, "add_texture", "rna_Main_add_texture");
|
||||
RNA_def_function_ui_description(func, "Add a new texture.");
|
||||
parm= RNA_def_string(func, "name", "Tex", 0, "", "New name for the datablock."); /* optional */
|
||||
@@ -223,5 +204,267 @@ void RNA_api_main(StructRNA *srna)
|
||||
|
||||
}
|
||||
|
||||
void RNA_def_main_cameras(BlenderRNA *brna, PropertyRNA *cprop)
|
||||
{
|
||||
StructRNA *srna;
|
||||
FunctionRNA *func;
|
||||
PropertyRNA *parm;
|
||||
|
||||
RNA_def_property_srna(cprop, "MainCameras");
|
||||
srna= RNA_def_struct(brna, "MainCameras", NULL);
|
||||
RNA_def_struct_sdna(srna, "Camera");
|
||||
RNA_def_struct_ui_text(srna, "Main Cameras", "Collection of cameras.");
|
||||
|
||||
func= RNA_def_function(srna, "new", "rna_Main_cameras_new");
|
||||
RNA_def_function_flag(func, FUNC_NO_SELF|FUNC_USE_CONTEXT);
|
||||
RNA_def_function_ui_description(func, "Add a new camera to the main database");
|
||||
parm= RNA_def_string(func, "name", "Camera", 0, "", "New name for the datablock.");
|
||||
RNA_def_property_flag(parm, PROP_REQUIRED);
|
||||
/* return type */
|
||||
parm= RNA_def_pointer(func, "camera", "Camera", "", "New camera datablock.");
|
||||
RNA_def_function_return(func, parm);
|
||||
|
||||
func= RNA_def_function(srna, "remove", "rna_Main_cameras_remove");
|
||||
RNA_def_function_flag(func, FUNC_NO_SELF|FUNC_USE_CONTEXT|FUNC_USE_REPORTS);
|
||||
RNA_def_function_ui_description(func, "Remove a camera from the current blendfile.");
|
||||
parm= RNA_def_pointer(func, "camera", "Camera", "", "Camera to remove.");
|
||||
RNA_def_property_flag(parm, PROP_REQUIRED);
|
||||
}
|
||||
|
||||
void RNA_def_main_scenes(BlenderRNA *brna, PropertyRNA *cprop)
|
||||
{
|
||||
StructRNA *srna;
|
||||
FunctionRNA *func;
|
||||
PropertyRNA *parm;
|
||||
|
||||
RNA_def_property_srna(cprop, "MainScenes");
|
||||
srna= RNA_def_struct(brna, "MainScenes", NULL);
|
||||
RNA_def_struct_sdna(srna, "Scene");
|
||||
RNA_def_struct_ui_text(srna, "Main Scenes", "Collection of scenes.");
|
||||
|
||||
func= RNA_def_function(srna, "new", "rna_Main_scenes_new");
|
||||
RNA_def_function_flag(func, FUNC_NO_SELF|FUNC_USE_CONTEXT);
|
||||
RNA_def_function_ui_description(func, "Add a new scene to the main database");
|
||||
parm= RNA_def_string(func, "name", "Scene", 0, "", "New name for the datablock.");
|
||||
RNA_def_property_flag(parm, PROP_REQUIRED);
|
||||
/* return type */
|
||||
parm= RNA_def_pointer(func, "scene", "Scene", "", "New scene datablock.");
|
||||
RNA_def_function_return(func, parm);
|
||||
|
||||
func= RNA_def_function(srna, "remove", "rna_Main_scenes_remove");
|
||||
RNA_def_function_flag(func, FUNC_NO_SELF|FUNC_USE_CONTEXT|FUNC_USE_REPORTS);
|
||||
parm= RNA_def_pointer(func, "scene", "Scene", "", "Scene to remove.");
|
||||
RNA_def_property_flag(parm, PROP_REQUIRED);
|
||||
RNA_def_function_ui_description(func, "Remove a scene from the current blendfile.");
|
||||
RNA_def_property_flag(parm, PROP_REQUIRED);
|
||||
}
|
||||
|
||||
void RNA_def_main_objects(BlenderRNA *brna, PropertyRNA *cprop)
|
||||
{
|
||||
StructRNA *srna;
|
||||
FunctionRNA *func;
|
||||
PropertyRNA *parm;
|
||||
|
||||
RNA_def_property_srna(cprop, "MainObjects");
|
||||
srna= RNA_def_struct(brna, "MainObjects", NULL);
|
||||
RNA_def_struct_sdna(srna, "Object");
|
||||
RNA_def_struct_ui_text(srna, "Main Objects", "Collection of objects.");
|
||||
|
||||
func= RNA_def_function(srna, "new", "rna_Main_objects_new");
|
||||
RNA_def_function_flag(func, FUNC_NO_SELF|FUNC_USE_CONTEXT);
|
||||
RNA_def_function_ui_description(func, "Add a new object to the main database");
|
||||
parm= RNA_def_string(func, "name", "Object", 0, "", "New name for the datablock.");
|
||||
RNA_def_property_flag(parm, PROP_REQUIRED);
|
||||
parm= RNA_def_enum(func, "type", object_type_items, 0, "", "Type of Object.");
|
||||
RNA_def_property_flag(parm, PROP_REQUIRED);
|
||||
|
||||
/* return type */
|
||||
parm= RNA_def_pointer(func, "object", "Object", "", "New object datablock.");
|
||||
RNA_def_function_return(func, parm);
|
||||
|
||||
func= RNA_def_function(srna, "remove", "rna_Main_objects_remove");
|
||||
RNA_def_function_flag(func, FUNC_NO_SELF|FUNC_USE_CONTEXT|FUNC_USE_REPORTS);
|
||||
parm= RNA_def_pointer(func, "object", "Object", "", "Object to remove.");
|
||||
RNA_def_property_flag(parm, PROP_REQUIRED);
|
||||
RNA_def_function_ui_description(func, "Remove a object from the current blendfile.");
|
||||
}
|
||||
|
||||
void RNA_def_main_materials(BlenderRNA *brna, PropertyRNA *cprop)
|
||||
{
|
||||
StructRNA *srna;
|
||||
FunctionRNA *func;
|
||||
PropertyRNA *parm;
|
||||
|
||||
RNA_def_property_srna(cprop, "MainMaterials");
|
||||
srna= RNA_def_struct(brna, "MainMaterials", NULL);
|
||||
RNA_def_struct_sdna(srna, "Material");
|
||||
RNA_def_struct_ui_text(srna, "Main Material", "Collection of materials.");
|
||||
|
||||
func= RNA_def_function(srna, "new", "rna_Main_materials_new");
|
||||
RNA_def_function_flag(func, FUNC_NO_SELF|FUNC_USE_CONTEXT);
|
||||
RNA_def_function_ui_description(func, "Add a new material to the main database");
|
||||
parm= RNA_def_string(func, "name", "Material", 0, "", "New name for the datablock.");
|
||||
RNA_def_property_flag(parm, PROP_REQUIRED);
|
||||
/* return type */
|
||||
parm= RNA_def_pointer(func, "material", "Material", "", "New material datablock.");
|
||||
RNA_def_function_return(func, parm);
|
||||
|
||||
func= RNA_def_function(srna, "remove", "rna_Main_materials_remove");
|
||||
RNA_def_function_flag(func, FUNC_NO_SELF|FUNC_USE_CONTEXT|FUNC_USE_REPORTS);
|
||||
RNA_def_function_ui_description(func, "Remove a material from the current blendfile.");
|
||||
parm= RNA_def_pointer(func, "material", "Material", "", "Material to remove.");
|
||||
RNA_def_property_flag(parm, PROP_REQUIRED);
|
||||
}
|
||||
void RNA_def_main_node_groups(BlenderRNA *brna, PropertyRNA *cprop)
|
||||
{
|
||||
|
||||
}
|
||||
void RNA_def_main_meshes(BlenderRNA *brna, PropertyRNA *cprop)
|
||||
{
|
||||
StructRNA *srna;
|
||||
FunctionRNA *func;
|
||||
PropertyRNA *parm;
|
||||
|
||||
RNA_def_property_srna(cprop, "MainMeshes");
|
||||
srna= RNA_def_struct(brna, "MainMeshes", NULL);
|
||||
RNA_def_struct_sdna(srna, "Mesh");
|
||||
RNA_def_struct_ui_text(srna, "Main Meshes", "Collection of meshes.");
|
||||
|
||||
func= RNA_def_function(srna, "new", "rna_Main_meshes_new");
|
||||
RNA_def_function_flag(func, FUNC_NO_SELF|FUNC_USE_CONTEXT);
|
||||
RNA_def_function_ui_description(func, "Add a new mesh to the main database");
|
||||
parm= RNA_def_string(func, "name", "Mesh", 0, "", "New name for the datablock.");
|
||||
RNA_def_property_flag(parm, PROP_REQUIRED);
|
||||
/* return type */
|
||||
parm= RNA_def_pointer(func, "mesh", "Mesh", "", "New mesh datablock.");
|
||||
RNA_def_function_return(func, parm);
|
||||
|
||||
func= RNA_def_function(srna, "remove", "rna_Main_meshes_remove");
|
||||
RNA_def_function_flag(func, FUNC_NO_SELF|FUNC_USE_CONTEXT|FUNC_USE_REPORTS);
|
||||
RNA_def_function_ui_description(func, "Remove a mesh from the current blendfile.");
|
||||
parm= RNA_def_pointer(func, "mesh", "Mesh", "", "Mesh to remove.");
|
||||
RNA_def_property_flag(parm, PROP_REQUIRED);
|
||||
}
|
||||
void RNA_def_main_lamps(BlenderRNA *brna, PropertyRNA *cprop)
|
||||
{
|
||||
StructRNA *srna;
|
||||
FunctionRNA *func;
|
||||
PropertyRNA *parm;
|
||||
|
||||
RNA_def_property_srna(cprop, "MainLamps");
|
||||
srna= RNA_def_struct(brna, "MainLamps", NULL);
|
||||
RNA_def_struct_sdna(srna, "Lamp");
|
||||
RNA_def_struct_ui_text(srna, "Main Lamps", "Collection of lamps.");
|
||||
|
||||
func= RNA_def_function(srna, "new", "rna_Main_lamps_new");
|
||||
RNA_def_function_flag(func, FUNC_NO_SELF|FUNC_USE_CONTEXT);
|
||||
RNA_def_function_ui_description(func, "Add a new lamp to the main database");
|
||||
parm= RNA_def_string(func, "name", "Lamp", 0, "", "New name for the datablock.");
|
||||
RNA_def_property_flag(parm, PROP_REQUIRED);
|
||||
/* return type */
|
||||
parm= RNA_def_pointer(func, "lamp", "Lamp", "", "New lamp datablock.");
|
||||
RNA_def_function_return(func, parm);
|
||||
|
||||
func= RNA_def_function(srna, "remove", "rna_Main_lamps_remove");
|
||||
RNA_def_function_flag(func, FUNC_NO_SELF|FUNC_USE_CONTEXT|FUNC_USE_REPORTS);
|
||||
RNA_def_function_ui_description(func, "Remove a lamp from the current blendfile.");
|
||||
parm= RNA_def_pointer(func, "lamp", "Lamp", "", "Lamp to remove.");
|
||||
RNA_def_property_flag(parm, PROP_REQUIRED);
|
||||
}
|
||||
void RNA_def_main_libraries(BlenderRNA *brna, PropertyRNA *cprop)
|
||||
{
|
||||
|
||||
}
|
||||
void RNA_def_main_screens(BlenderRNA *brna, PropertyRNA *cprop)
|
||||
{
|
||||
|
||||
}
|
||||
void RNA_def_main_window_managers(BlenderRNA *brna, PropertyRNA *cprop)
|
||||
{
|
||||
|
||||
}
|
||||
void RNA_def_main_images(BlenderRNA *brna, PropertyRNA *cprop)
|
||||
{
|
||||
|
||||
}
|
||||
void RNA_def_main_lattices(BlenderRNA *brna, PropertyRNA *cprop)
|
||||
{
|
||||
|
||||
}
|
||||
void RNA_def_main_curves(BlenderRNA *brna, PropertyRNA *cprop)
|
||||
{
|
||||
|
||||
}
|
||||
void RNA_def_main_metaballs(BlenderRNA *brna, PropertyRNA *cprop)
|
||||
{
|
||||
|
||||
}
|
||||
void RNA_def_main_vfonts(BlenderRNA *brna, PropertyRNA *cprop)
|
||||
{
|
||||
|
||||
}
|
||||
void RNA_def_main_textures(BlenderRNA *brna, PropertyRNA *cprop)
|
||||
{
|
||||
|
||||
}
|
||||
void RNA_def_main_brushes(BlenderRNA *brna, PropertyRNA *cprop)
|
||||
{
|
||||
|
||||
}
|
||||
void RNA_def_main_worlds(BlenderRNA *brna, PropertyRNA *cprop)
|
||||
{
|
||||
|
||||
}
|
||||
void RNA_def_main_groups(BlenderRNA *brna, PropertyRNA *cprop)
|
||||
{
|
||||
|
||||
}
|
||||
void RNA_def_main_texts(BlenderRNA *brna, PropertyRNA *cprop)
|
||||
{
|
||||
|
||||
}
|
||||
void RNA_def_main_sounds(BlenderRNA *brna, PropertyRNA *cprop)
|
||||
{
|
||||
|
||||
}
|
||||
void RNA_def_main_armatures(BlenderRNA *brna, PropertyRNA *cprop)
|
||||
{
|
||||
StructRNA *srna;
|
||||
FunctionRNA *func;
|
||||
PropertyRNA *parm;
|
||||
|
||||
RNA_def_property_srna(cprop, "MainArmatures");
|
||||
srna= RNA_def_struct(brna, "MainArmatures", NULL);
|
||||
RNA_def_struct_sdna(srna, "Armature");
|
||||
RNA_def_struct_ui_text(srna, "Main Armatures", "Collection of armatures.");
|
||||
|
||||
func= RNA_def_function(srna, "new", "rna_Main_armatures_new");
|
||||
RNA_def_function_flag(func, FUNC_NO_SELF|FUNC_USE_CONTEXT);
|
||||
RNA_def_function_ui_description(func, "Add a new armature to the main database");
|
||||
parm= RNA_def_string(func, "name", "Armature", 0, "", "New name for the datablock.");
|
||||
RNA_def_property_flag(parm, PROP_REQUIRED);
|
||||
/* return type */
|
||||
parm= RNA_def_pointer(func, "armature", "Armature", "", "New armature datablock.");
|
||||
RNA_def_function_return(func, parm);
|
||||
|
||||
func= RNA_def_function(srna, "remove", "rna_Main_armatures_remove");
|
||||
RNA_def_function_flag(func, FUNC_NO_SELF|FUNC_USE_CONTEXT|FUNC_USE_REPORTS);
|
||||
RNA_def_function_ui_description(func, "Remove a armature from the current blendfile.");
|
||||
parm= RNA_def_pointer(func, "armature", "Armature", "", "Armature to remove.");
|
||||
RNA_def_property_flag(parm, PROP_REQUIRED);
|
||||
}
|
||||
void RNA_def_main_actions(BlenderRNA *brna, PropertyRNA *cprop)
|
||||
{
|
||||
|
||||
}
|
||||
void RNA_def_main_particles(BlenderRNA *brna, PropertyRNA *cprop)
|
||||
{
|
||||
|
||||
}
|
||||
void RNA_def_main_gpencil(BlenderRNA *brna, PropertyRNA *cprop)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -126,21 +126,28 @@ static PointerRNA rna_Scene_objects_get(CollectionPropertyIterator *iter)
|
||||
return rna_pointer_inherit_refine(&iter->parent, &RNA_Object, ((Base*)internal->link)->object);
|
||||
}
|
||||
|
||||
static void rna_Scene_link_object(Scene *sce, ReportList *reports, Object *ob)
|
||||
static void rna_Scene_link_object(Scene *scene, ReportList *reports, Object *ob)
|
||||
{
|
||||
Base *base= object_in_scene(ob, sce);
|
||||
if (base) {
|
||||
BKE_report(reports, RPT_ERROR, "Object is already in this scene.");
|
||||
Base *base;
|
||||
|
||||
if (ob->type != OB_EMPTY && ob->data==NULL) {
|
||||
BKE_reportf(reports, RPT_ERROR, "Object \"%s\" is not an Empty type and has no Object Data set.");
|
||||
return;
|
||||
}
|
||||
base= scene_add_base(sce, ob);
|
||||
|
||||
if (object_in_scene(ob, scene)) {
|
||||
BKE_reportf(reports, RPT_ERROR, "Object \"%s\" is already in scene \"%s\".", ob->id.name+2, scene->id.name+2);
|
||||
return;
|
||||
}
|
||||
|
||||
base= scene_add_base(scene, ob);
|
||||
ob->id.us++;
|
||||
|
||||
/* this is similar to what object_add_type and add_object do */
|
||||
ob->lay= base->lay= sce->lay;
|
||||
ob->lay= base->lay= scene->lay;
|
||||
ob->recalc |= OB_RECALC;
|
||||
|
||||
DAG_scene_sort(sce);
|
||||
DAG_scene_sort(scene);
|
||||
}
|
||||
|
||||
static void rna_Scene_unlink_object(Scene *sce, ReportList *reports, Object *ob)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
|
||||
/**
|
||||
* $Id$
|
||||
*
|
||||
@@ -2005,6 +2006,16 @@ static PyObject *pyrna_prop_getattro( BPy_PropertyRNA *self, PyObject *pyname )
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* annoying exception, maybe we need to have different types for this... */
|
||||
if((strcmp(name, "__getitem__")==0 || strcmp(name, "__setitem__")==0) &&
|
||||
(RNA_property_type(self->prop) != PROP_COLLECTION) &&
|
||||
RNA_property_array_check(&self->ptr, self->prop)==0
|
||||
) {
|
||||
PyErr_SetString(PyExc_AttributeError, "PropertyRNA - no __getitem__ support for this type");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* The error raised here will be displayed */
|
||||
return PyObject_GenericGetAttr((PyObject *)self, pyname);
|
||||
|
||||
Reference in New Issue
Block a user