[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [27681] trunk/blender/source/blender/ makesrna: py/rna functions for adding and removing curve data.

Brecht Van Lommel brecht at blender.org
Tue Mar 23 15:58:38 CET 2010


Revision: 27681
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=27681
Author:   blendix
Date:     2010-03-23 15:58:36 +0100 (Tue, 23 Mar 2010)

Log Message:
-----------
py/rna functions for adding and removing curve data.
(commit 27666 by Campbell from render25 branch)

Modified Paths:
--------------
    trunk/blender/source/blender/makesrna/RNA_enum_types.h
    trunk/blender/source/blender/makesrna/RNA_types.h
    trunk/blender/source/blender/makesrna/intern/rna_main_api.c
    trunk/blender/source/blender/makesrna/intern/rna_object.c

Modified: trunk/blender/source/blender/makesrna/RNA_enum_types.h
===================================================================
--- trunk/blender/source/blender/makesrna/RNA_enum_types.h	2010-03-23 14:58:25 UTC (rev 27680)
+++ trunk/blender/source/blender/makesrna/RNA_enum_types.h	2010-03-23 14:58:36 UTC (rev 27681)
@@ -73,6 +73,8 @@
 
 extern EnumPropertyItem object_type_items[];
 
+extern EnumPropertyItem object_type_curve_items[];
+
 extern EnumPropertyItem space_type_items[];
 
 extern EnumPropertyItem keymap_propvalue_items[];

Modified: trunk/blender/source/blender/makesrna/RNA_types.h
===================================================================
--- trunk/blender/source/blender/makesrna/RNA_types.h	2010-03-23 14:58:25 UTC (rev 27680)
+++ trunk/blender/source/blender/makesrna/RNA_types.h	2010-03-23 14:58:36 UTC (rev 27681)
@@ -340,6 +340,7 @@
 #define MainActions Main
 #define MainGroups Main
 #define MainTextures Main
+#define MainCurves Main
 
 #ifdef __cplusplus
 }

Modified: trunk/blender/source/blender/makesrna/intern/rna_main_api.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_main_api.c	2010-03-23 14:58:25 UTC (rev 27680)
+++ trunk/blender/source/blender/makesrna/intern/rna_main_api.c	2010-03-23 14:58:36 UTC (rev 27681)
@@ -54,6 +54,7 @@
 
 #include "DNA_armature_types.h"
 #include "DNA_camera_types.h"
+#include "DNA_curve_types.h"
 #include "DNA_lamp_types.h"
 #include "DNA_material_types.h"
 #include "DNA_mesh_types.h"
@@ -243,6 +244,20 @@
 	/* XXX python now has invalid pointer? */
 }
 
+Curve *rna_Main_curves_new(Main *bmain, char* name, int type)
+{
+	Curve *cu= add_curve(name, type);
+	cu->id.us--;
+	return cu;
+}
+void rna_Main_curves_remove(Main *bmain, ReportList *reports, struct Curve *cu)
+{
+	if(ID_REAL_USERS(cu) <= 0)
+		free_libblock(&bmain->curve, cu);
+	else
+		BKE_reportf(reports, RPT_ERROR, "Curve \"%s\" must have zero users to be removed, found %d.", cu->id.name+2, ID_REAL_USERS(cu));
+}
+
 Tex *rna_Main_textures_new(Main *bmain, char* name)
 {
 	Tex *tex= add_texture(name);
@@ -508,7 +523,7 @@
 }
 void RNA_def_main_window_managers(BlenderRNA *brna, PropertyRNA *cprop)
 {
-
+    
 }
 void RNA_def_main_images(BlenderRNA *brna, PropertyRNA *cprop)
 {
@@ -552,7 +567,29 @@
 }
 void RNA_def_main_curves(BlenderRNA *brna, PropertyRNA *cprop)
 {
+	StructRNA *srna;
+	FunctionRNA *func;
+	PropertyRNA *parm;
 
+	RNA_def_property_srna(cprop, "MainCurves");
+	srna= RNA_def_struct(brna, "MainCurves", NULL);
+	RNA_def_struct_ui_text(srna, "Main Curves", "Collection of curves");
+
+	func= RNA_def_function(srna, "new", "rna_Main_curves_new");
+	RNA_def_function_ui_description(func, "Add a new curve to the main database");
+	parm= RNA_def_string(func, "name", "Curve", 0, "", "New name for the datablock.");
+	RNA_def_property_flag(parm, PROP_REQUIRED);
+	parm= RNA_def_enum(func, "type", object_type_curve_items, 0, "Type", "The type of curve object to add");
+	RNA_def_property_flag(parm, PROP_REQUIRED);
+	/* return type */
+	parm= RNA_def_pointer(func, "curve", "Curve", "", "New curve datablock.");
+	RNA_def_function_return(func, parm);
+
+	func= RNA_def_function(srna, "remove", "rna_Main_curves_remove");
+	RNA_def_function_flag(func, FUNC_USE_REPORTS);
+	RNA_def_function_ui_description(func, "Remove a curve from the current blendfile.");
+	parm= RNA_def_pointer(func, "curve", "Curve", "", "Curve to remove.");
+	RNA_def_property_flag(parm, PROP_REQUIRED);
 }
 void RNA_def_main_metaballs(BlenderRNA *brna, PropertyRNA *cprop)
 {

Modified: trunk/blender/source/blender/makesrna/intern/rna_object.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_object.c	2010-03-23 14:58:25 UTC (rev 27680)
+++ trunk/blender/source/blender/makesrna/intern/rna_object.c	2010-03-23 14:58:36 UTC (rev 27681)
@@ -76,12 +76,17 @@
 	//{OB_DYN_MESH, "DYNAMIC_MESH", 0, "Dynamic Mesh", ""},
 	{0, NULL, 0, NULL, NULL}};
 
+/* used for 2 enums */
+#define OBTYPE_CU_CURVE {OB_CURVE, "CURVE", 0, "Curve", ""}
+#define OBTYPE_CU_SURF {OB_SURF, "SURFACE", 0, "Surface", ""}
+#define OBTYPE_CU_TEXT {OB_FONT, "TEXT", 0, "Text", ""}
+    
 EnumPropertyItem object_type_items[] = {
 	{OB_MESH, "MESH", 0, "Mesh", ""},
-	{OB_CURVE, "CURVE", 0, "Curve", ""},
-	{OB_SURF, "SURFACE", 0, "Surface", ""},
+	OBTYPE_CU_CURVE,
+	OBTYPE_CU_SURF,
 	{OB_MBALL, "META", 0, "Meta", ""},
-	{OB_FONT, "TEXT", 0, "Text", ""},
+	OBTYPE_CU_TEXT,
 	{0, "", 0, NULL, NULL},
 	{OB_ARMATURE, "ARMATURE", 0, "Armature", ""},
 	{OB_LATTICE, "LATTICE", 0, "Lattice", ""},
@@ -91,6 +96,12 @@
 	{OB_LAMP, "LAMP", 0, "Lamp", ""},
 	{0, NULL, 0, NULL, NULL}};
 
+EnumPropertyItem object_type_curve_items[] = {
+	OBTYPE_CU_CURVE,
+	OBTYPE_CU_SURF,
+	OBTYPE_CU_TEXT,
+	{0, NULL, 0, NULL, NULL}};
+    
 #ifdef RNA_RUNTIME
 
 #include "BLI_math.h"





More information about the Bf-blender-cvs mailing list