Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/makesrna/intern/rna_object_api.c')
-rw-r--r--source/blender/makesrna/intern/rna_object_api.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c
index 9fb883568c9..df628caa000 100644
--- a/source/blender/makesrna/intern/rna_object_api.c
+++ b/source/blender/makesrna/intern/rna_object_api.c
@@ -404,6 +404,29 @@ static void rna_Object_to_mesh_clear(Object *object)
BKE_object_to_mesh_clear(object);
}
+static Curve *rna_Object_to_curve(Object *object,
+ ReportList *reports,
+ Depsgraph *depsgraph,
+ bool apply_modifiers)
+{
+ if (!ELEM(object->type, OB_FONT, OB_CURVE)) {
+ BKE_report(reports, RPT_ERROR, "Object is not a curve or a text");
+ return NULL;
+ }
+
+ if (depsgraph == NULL) {
+ BKE_report(reports, RPT_ERROR, "Invalid depsgraph");
+ return NULL;
+ }
+
+ return BKE_object_to_curve(object, depsgraph, apply_modifiers);
+}
+
+static void rna_Object_to_curve_clear(Object *object)
+{
+ BKE_object_to_curve_clear(object);
+}
+
static PointerRNA rna_Object_shape_key_add(
Object *ob, bContext *C, ReportList *reports, const char *name, bool from_mix)
{
@@ -977,6 +1000,29 @@ void RNA_api_object(StructRNA *srna)
func = RNA_def_function(srna, "to_mesh_clear", "rna_Object_to_mesh_clear");
RNA_def_function_ui_description(func, "Clears mesh data-block created by to_mesh()");
+ /* curve */
+ func = RNA_def_function(srna, "to_curve", "rna_Object_to_curve");
+ RNA_def_function_ui_description(
+ func,
+ "Create a Curve data-block from the current state of the object. This only works for curve "
+ "and text objects. The object owns the data-block. To force free it, use to_curve_clear(). "
+ "The result is temporary and can not be used by objects from the main database");
+ RNA_def_function_flag(func, FUNC_USE_REPORTS);
+ parm = RNA_def_pointer(
+ func, "depsgraph", "Depsgraph", "Dependency Graph", "Evaluated dependency graph");
+ RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
+ RNA_def_boolean(func,
+ "apply_modifiers",
+ false,
+ "",
+ "Apply the deform modifiers on the control points of the curve. This is only "
+ "supported for curve objects");
+ parm = RNA_def_pointer(func, "curve", "Curve", "", "Curve created from object");
+ RNA_def_function_return(func, parm);
+
+ func = RNA_def_function(srna, "to_curve_clear", "rna_Object_to_curve_clear");
+ RNA_def_function_ui_description(func, "Clears curve data-block created by to_curve()");
+
/* Armature */
func = RNA_def_function(srna, "find_armature", "BKE_modifiers_is_deformed_by_armature");
RNA_def_function_ui_description(