diff options
-rw-r--r-- | release/scripts/io/engine_render_pov.py | 2 | ||||
-rw-r--r-- | release/scripts/io/export_3ds.py | 2 | ||||
-rw-r--r-- | release/scripts/io/export_fbx.py | 5 | ||||
-rw-r--r-- | release/scripts/io/export_obj.py | 27 | ||||
-rw-r--r-- | release/scripts/io/export_ply.py | 2 | ||||
-rw-r--r-- | release/scripts/io/export_x3d.py | 2 | ||||
-rw-r--r-- | release/scripts/io/import_scene_3ds.py | 9 | ||||
-rw-r--r-- | release/scripts/io/import_scene_obj.py | 5 | ||||
-rw-r--r-- | release/scripts/modules/retopo.py | 37 | ||||
-rw-r--r-- | release/scripts/modules/rigify/__init__.py | 4 | ||||
-rw-r--r-- | release/scripts/op/add_mesh_torus.py | 4 | ||||
-rw-r--r-- | release/scripts/op/object.py | 1 | ||||
-rw-r--r-- | release/scripts/ui/space_nla.py | 5 | ||||
-rw-r--r-- | release/scripts/ui/space_view3d_toolbar.py | 3 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_regions.c | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_internal.h | 27 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_main.c | 67 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_main_api.c | 435 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_scene.c | 21 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_rna.c | 11 |
20 files changed, 481 insertions, 190 deletions
diff --git a/release/scripts/io/engine_render_pov.py b/release/scripts/io/engine_render_pov.py index 3ad75f41709..5275574d903 100644 --- a/release/scripts/io/engine_render_pov.py +++ b/release/scripts/io/engine_render_pov.py @@ -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: diff --git a/release/scripts/io/export_3ds.py b/release/scripts/io/export_3ds.py index 23fd44acc3f..979c53c581d 100644 --- a/release/scripts/io/export_3ds.py +++ b/release/scripts/io/export_3ds.py @@ -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 diff --git a/release/scripts/io/export_fbx.py b/release/scripts/io/export_fbx.py index 22e75f65705..a7e126446bd 100644 --- a/release/scripts/io/export_fbx.py +++ b/release/scripts/io/export_fbx.py @@ -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: diff --git a/release/scripts/io/export_obj.py b/release/scripts/io/export_obj.py index 50a40f4662c..8d1a9a9aced 100644 --- a/release/scripts/io/export_obj.py +++ b/release/scripts/io/export_obj.py @@ -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() diff --git a/release/scripts/io/export_ply.py b/release/scripts/io/export_ply.py index 6f28b79c8f0..58f65e928cf 100644 --- a/release/scripts/io/export_ply.py +++ b/release/scripts/io/export_ply.py @@ -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 """ diff --git a/release/scripts/io/export_x3d.py b/release/scripts/io/export_x3d.py index 4c3540a458e..6b94a0cc91a 100644 --- a/release/scripts/io/export_x3d.py +++ b/release/scripts/io/export_x3d.py @@ -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": diff --git a/release/scripts/io/import_scene_3ds.py b/release/scripts/io/import_scene_3ds.py index 4420f6ef6f0..5f55b169d27 100644 --- a/release/scripts/io/import_scene_3ds.py +++ b/release/scripts/io/import_scene_3ds.py @@ -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 diff --git a/release/scripts/io/import_scene_obj.py b/release/scripts/io/import_scene_obj.py index 59fbef5b8ad..001ed923699 100644 --- a/release/scripts/io/import_scene_obj.py +++ b/release/scripts/io/import_scene_obj.py @@ -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) diff --git a/release/scripts/modules/retopo.py b/release/scripts/modules/retopo.py index 1ea5f7f854d..6fba34b7b58 100644 --- a/release/scripts/modules/retopo.py +++ b/release/scripts/modules/retopo.py @@ -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) diff --git a/release/scripts/modules/rigify/__init__.py b/release/scripts/modules/rigify/__init__.py index 6163ffbe950..6857d7e8f6d 100644 --- a/release/scripts/modules/rigify/__init__.py +++ b/release/scripts/modules/rigify/__init__.py @@ -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 diff --git a/release/scripts/op/add_mesh_torus.py b/release/scripts/op/add_mesh_torus.py index 372afb3654f..865b1d57daf 100644 --- a/release/scripts/op/add_mesh_torus.py +++ b/release/scripts/op/add_mesh_torus.py @@ -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 diff --git a/release/scripts/op/object.py b/release/scripts/op/object.py index d68c30f0f23..dd95c6f51a6 100644 --- a/release/scripts/op/object.py +++ b/release/scripts/op/object.py @@ -145,6 +145,7 @@ class Retopo(bpy.types.Operator): def execute(self, context): import retopo + reload(retopo) retopo.main() return {'FINISHED'} diff --git a/release/scripts/ui/space_nla.py b/release/scripts/ui/space_nla.py index 285ada5f46e..0060941b476 100644 --- a/release/scripts/ui/space_nla.py +++ b/release/scripts/ui/space_nla.py @@ -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") diff --git a/release/scripts/ui/space_view3d_toolbar.py b/release/scripts/ui/space_view3d_toolbar.py index 52b0cf3d0f8..e3c0c2d24b1 100644 --- a/release/scripts/ui/space_view3d_toolbar.py +++ b/release/scripts/ui/space_view3d_toolbar.py @@ -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 diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index 812a1e6882b..6bc4e7b0b65 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -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); } diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h index b154647e10e..3d18804036a 100644 --- a/source/blender/makesrna/intern/rna_internal.h +++ b/source/blender/makesrna/intern/rna_internal.h @@ -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; diff --git a/source/blender/makesrna/intern/rna_main.c b/source/blender/makesrna/intern/rna_main.c index 82988a06af9..4b5a404b268 100644 --- a/source/blender/makesrna/intern/rna_main.c +++ b/source/blender/makesrna/intern/rna_main.c @@ -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); diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c index 5069bbd6ae6..ecaf6f813da 100644 --- a/source/blender/makesrna/intern/rna_main_api.c +++ b/source/blender/makesrna/intern/rna_main_api.c @@ -43,108 +43,143 @@ #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) +static Tex *rna_Main_add_texture(Main *bmain, char *name) { - Mesh *me= add_mesh(name); - me->id.us--; - return me; + return add_texture(name); } -static void rna_Main_remove_mesh(Main *bmain, ReportList *reports, Mesh *me) +/* TODO: remove texture? */ + +static Image *rna_Main_add_image(Main *bmain, char *filename) { - 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? */ + return BKE_add_image_file(filename, 0); } -static void rna_Main_remove_armature(Main *bmain, ReportList *reports, bArmature *arm) +static Camera *rna_Main_cameras_new(bContext *C, char* name) { - if(arm->id.us == 0) - free_libblock(&bmain->armature, arm); + 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_report(reports, RPT_ERROR, "Armature must have zero users to be removed."); + 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 bArmature *rna_Main_add_armature(Main *bmain, char *name) +static Scene *rna_Main_scenes_new(bContext *C, 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; + return add_scene(name); } - -/* -static void rna_Main_remove_lamp(Main *bmain, ReportList *reports, Lamp *la) +static void rna_Main_scenes_remove(bContext *C, ReportList *reports, struct Scene *scene) { - if(la->id.us == 0) - free_libblock(&main->lamp, la); - else - BKE_report(reports, RPT_ERROR, "Lamp must have zero users to be removed."); + Main *bmain= CTX_data_main(C); + free_libblock(&bmain->scene, scene); } -*/ -static Object* rna_Main_add_object(Main *bmain, int type, char *name) +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 -/* - NOTE: the following example shows when this function should _not_ be called + ob = bpy.data.add_object() + scene.add_object(ob) - ob = bpy.data.add_object() - scene.add_object(ob) + # ob is freed here + scene.remove_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); +} - # 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) +static Material *rna_Main_materials_new(bContext *C, char* name) { - if(ob->id.us == 0) - free_libblock(&bmain->object, ob); + 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_report(reports, RPT_ERROR, "Object must have zero users to be removed."); + 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 Material *rna_Main_add_material(Main *bmain, char *name) +static Mesh *rna_Main_meshes_new(bContext *C, char* name) { - return add_material(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); -/* TODO: remove material? */ + /* XXX python now has invalid pointer? */ +} -struct Tex *rna_Main_add_texture(Main *bmain, char *name) +static Lamp *rna_Main_lamps_new(bContext *C, char* name) { - return add_texture(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); -/* TODO: remove texture? */ + /* XXX python now has invalid pointer? */ +} -struct Image *rna_Main_add_image(Main *bmain, char *filename) +static bArmature *rna_Main_armatures_new(bContext *C, char* name) { - return BKE_add_image_file(filename, 0); + 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 @@ -154,73 +189,281 @@ 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."); + 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 */ + parm= RNA_def_pointer(func, "texture", "Texture", "", "New texture."); + RNA_def_function_return(func, parm); + + func= RNA_def_function(srna, "add_image", "rna_Main_add_image"); + RNA_def_function_ui_description(func, "Add a new image."); + parm= RNA_def_string(func, "filename", "", 0, "", "Filename to load image from."); + RNA_def_property_flag(parm, PROP_REQUIRED); + parm= RNA_def_pointer(func, "image", "Image", "", "New image."); + RNA_def_function_return(func, parm); + +} + +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_pointer(func, "object", "Object", "", "New object."); + 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_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."); + 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."); +} - 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."); +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); - parm= RNA_def_pointer(func, "mesh", "Mesh", "", "New mesh."); + /* return type */ + parm= RNA_def_pointer(func, "material", "Material", "", "New material datablock."); 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."); + 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) +{ - 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."); +} +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); - parm= RNA_def_pointer(func, "armature", "Armature", "", "New armature."); + /* return type */ + parm= RNA_def_pointer(func, "mesh", "Mesh", "", "New mesh datablock."); 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."); + 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, "add_lamp", "rna_Main_add_lamp"); - RNA_def_function_ui_description(func, "Add a new lamp."); + 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); - parm= RNA_def_pointer(func, "mesh", "Lamp", "", "New lamp."); + /* return type */ + parm= RNA_def_pointer(func, "lamp", "Lamp", "", "New lamp datablock."); 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, "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) +{ - 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 */ - parm= RNA_def_pointer(func, "texture", "Texture", "", "New texture."); - RNA_def_function_return(func, parm); +} +void RNA_def_main_screens(BlenderRNA *brna, PropertyRNA *cprop) +{ - func= RNA_def_function(srna, "add_image", "rna_Main_add_image"); - RNA_def_function_ui_description(func, "Add a new image."); - parm= RNA_def_string(func, "filename", "", 0, "", "Filename to load image from."); +} +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); - parm= RNA_def_pointer(func, "image", "Image", "", "New image."); + /* 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 diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 72a5ac9a552..82c7de36eab 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -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) diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 34e4599f463..ace638914dc 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -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); |