From 7884406f33c91a5161b570ef53d84450e3775a24 Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Fri, 17 Feb 2017 12:57:12 +0100 Subject: Layers: ob.visible_get() Similar to ob.select_get(), but for BASE_VISIBLED. --- source/blender/makesrna/intern/rna_object_api.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'source/blender/makesrna/intern/rna_object_api.c') diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c index c93f72e798f..0390ba04223 100644 --- a/source/blender/makesrna/intern/rna_object_api.c +++ b/source/blender/makesrna/intern/rna_object_api.c @@ -135,6 +135,19 @@ static int rna_Object_select_get(Object *ob, bContext *C, ReportList *reports) return ((base->flag & BASE_SELECTED) != 0) ? 1 : 0; } +static int rna_Object_visible_get(Object *ob, bContext *C, ReportList *reports) +{ + SceneLayer *sl = CTX_data_scene_layer(C); + Base *base = BKE_scene_layer_base_find(sl, ob); + + if (!base) { + BKE_reportf(reports, RPT_ERROR, "Object '%s' not in Render Layer '%s'!", ob->id.name + 2, sl->name); + return -1; + } + + return ((base->flag & BASE_VISIBLED) != 0) ? 1 : 0; +} + /* Convert a given matrix from a space to another (using the object and/or a bone as reference). */ static void rna_Scene_mat_convert_space(Object *ob, ReportList *reports, bPoseChannel *pchan, float *mat, float *mat_ret, int from, int to) @@ -569,6 +582,12 @@ void RNA_api_object(StructRNA *srna) parm = RNA_def_boolean(func, "result", 0, "", "Object selected"); RNA_def_function_return(func, parm); + func = RNA_def_function(srna, "visible_get", "rna_Object_visible_get"); + RNA_def_function_ui_description(func, "Get the object visibility for the active render layer"); + RNA_def_function_flag(func, FUNC_USE_CONTEXT | FUNC_USE_REPORTS); + parm = RNA_def_boolean(func, "result", 0, "", "Object visible"); + RNA_def_function_return(func, parm); + /* Matrix space conversion */ func = RNA_def_function(srna, "convert_space", "rna_Scene_mat_convert_space"); RNA_def_function_ui_description(func, "Convert (transform) the given matrix from one space to another"); -- cgit v1.2.3