diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2017-02-17 14:57:12 +0300 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2017-02-17 14:57:14 +0300 |
commit | 7884406f33c91a5161b570ef53d84450e3775a24 (patch) | |
tree | c2a3045d34eda533374567bb87629bdf0ef3653f /source/blender/makesrna | |
parent | 5a14578116488b23a22f49d0aee2eac3b036abbd (diff) |
Layers: ob.visible_get()
Similar to ob.select_get(), but for BASE_VISIBLED.
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r-- | source/blender/makesrna/intern/rna_object_api.c | 19 |
1 files changed, 19 insertions, 0 deletions
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"); |