2 * ***** BEGIN GPL LICENSE BLOCK *****
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * The Original Code is Copyright (C) 2009 Blender Foundation.
19 * All rights reserved.
22 * Contributor(s): Blender Foundation
24 * ***** END GPL LICENSE BLOCK *****
27 /** \file blender/makesrna/intern/rna_object_api.c
37 #include "RNA_define.h"
39 #include "DNA_object_types.h"
40 #include "DNA_modifier_types.h"
42 #include "rna_internal.h" /* own include */
48 #include "BKE_global.h"
49 #include "BKE_context.h"
50 #include "BKE_report.h"
51 #include "BKE_object.h"
53 #include "BKE_DerivedMesh.h"
54 #include "BKE_bvhutils.h"
56 #include "BKE_customdata.h"
58 #include "BKE_depsgraph.h"
59 #include "BKE_displist.h"
61 #include "BKE_mball.h"
62 #include "BKE_modifier.h"
63 #include "BKE_cdderivedmesh.h"
65 #include "DNA_mesh_types.h"
66 #include "DNA_scene_types.h"
67 #include "DNA_meshdata_types.h"
68 #include "DNA_curve_types.h"
69 #include "DNA_modifier_types.h"
70 #include "DNA_constraint_types.h"
71 #include "DNA_view3d_types.h"
73 #include "MEM_guardedalloc.h"
75 /* copied from Mesh_getFromObject and adapted to RNA interface */
76 /* settings: 0 - preview, 1 - render */
77 static Mesh *rna_Object_to_mesh(Object *ob, ReportList *reports, Scene *sce, int apply_modifiers, int settings)
80 Curve *tmpcu = NULL, *copycu;
81 Object *tmpobj = NULL;
82 int render = settings == eModifierMode_Render, i;
83 int cage = !apply_modifiers;
85 /* perform the mesh extraction based on type */
91 ListBase dispbase = {NULL, NULL};
92 DerivedMesh *derivedFinal = NULL;
95 int (*orco_index)[4] = NULL;
96 float (*orco)[3] = NULL;
98 /* copies object and modifiers (but not the data) */
99 tmpobj = BKE_object_copy(ob);
100 tmpcu = (Curve *)tmpobj->data;
103 /* if getting the original caged mesh, delete object modifiers */
105 BKE_object_free_modifiers(tmpobj);
107 /* copies the data */
108 copycu = tmpobj->data = BKE_curve_copy((Curve *) ob->data);
110 /* temporarily set edit so we get updates from edit mode, but
111 * also because for text datablocks copying it while in edit
112 * mode gives invalid data structures */
113 copycu->editfont = tmpcu->editfont;
114 copycu->editnurb = tmpcu->editnurb;
116 /* get updated display list, and convert to a mesh */
117 BKE_displist_make_curveTypes_forRender(sce, tmpobj, &dispbase, &derivedFinal, FALSE);
119 copycu->editfont = NULL;
120 copycu->editnurb = NULL;
122 tmpobj->derivedFinal = derivedFinal;
124 uv_from_orco = (tmpcu->flag & CU_UV_ORCO) != 0;
127 /* before curve conversion */
128 orco = (float (*)[3])BKE_curve_make_orco(sce, tmpobj);
131 /* convert object type to mesh */
132 BKE_mesh_from_nurbs_displist(tmpobj, &dispbase, uv_from_orco ? (int **)&orco_index : NULL);
134 tmpmesh = tmpobj->data;
136 if (uv_from_orco && orco && orco_index) {
137 const char *uvname = "Orco";
139 MTexPoly *mtpoly = CustomData_add_layer_named(&tmpmesh->pdata, CD_MTEXPOLY, CD_DEFAULT, NULL, tmpmesh->totpoly, uvname);
140 MLoopUV *mloopuvs = CustomData_add_layer_named(&tmpmesh->ldata, CD_MLOOPUV, CD_DEFAULT, NULL, tmpmesh->totloop, uvname);
142 BKE_mesh_nurbs_to_mdata_orco(tmpmesh->mpoly, tmpmesh->totpoly,
143 tmpmesh->mloop, mloopuvs,
150 MEM_freeN(orco_index);
156 BKE_displist_free(&dispbase);
158 /* BKE_mesh_from_nurbs changes the type to a mesh, check it worked */
159 if (tmpobj->type != OB_MESH) {
160 BKE_libblock_free_us(&(G.main->object), tmpobj);
161 BKE_report(reports, RPT_ERROR, "cant convert curve to mesh. Does the curve have any segments?");
165 BKE_libblock_free_us(&G.main->object, tmpobj);
171 /* metaballs don't have modifiers, so just convert to mesh */
172 Object *basis_ob = BKE_mball_basis_find(sce, ob);
173 /* todo, re-generatre for render-res */
174 /* metaball_polygonize(scene, ob) */
177 return NULL; /* only do basis metaball */
179 tmpmesh = BKE_mesh_add("Mesh");
182 ListBase disp = {NULL, NULL};
183 BKE_displist_make_mball_forRender(sce, ob, &disp);
184 BKE_mesh_from_metaball(&disp, tmpmesh);
185 BKE_displist_free(&disp);
188 BKE_mesh_from_metaball(&ob->disp, tmpmesh);
193 /* copies object and modifiers (but not the data) */
195 /* copies the data */
196 tmpmesh = BKE_mesh_copy(ob->data);
197 /* if not getting the original caged mesh, get final derived mesh */
200 /* Make a dummy mesh, saves copying */
202 /* CustomDataMask mask = CD_MASK_BAREMESH|CD_MASK_MTFACE|CD_MASK_MCOL; */
203 CustomDataMask mask = CD_MASK_MESH; /* this seems more suitable, exporter,
204 * for example, needs CD_MASK_MDEFORMVERT */
206 /* Write the display mesh into the dummy mesh */
208 dm = mesh_create_derived_render(sce, ob, mask);
210 dm = mesh_create_derived_view(sce, ob, mask);
212 tmpmesh = BKE_mesh_add("Mesh");
213 DM_to_mesh(dm, tmpmesh, ob);
219 BKE_report(reports, RPT_ERROR, "Object does not have geometry data");
223 /* Copy materials to new mesh */
228 tmpmesh->totcol = tmpcu->totcol;
230 /* free old material list (if it exists) and adjust user counts */
232 for (i = tmpcu->totcol; i-- > 0; ) {
233 /* are we an object material or data based? */
235 tmpmesh->mat[i] = ob->matbits[i] ? ob->mat[i] : tmpcu->mat[i];
237 if (tmpmesh->mat[i]) {
238 tmpmesh->mat[i]->id.us++;
245 /* Crashes when assigning the new material, not sure why */
247 tmpmb = (MetaBall *)ob->data;
248 tmpmesh->totcol = tmpmb->totcol;
250 /* free old material list (if it exists) and adjust user counts */
252 for (i = tmpmb->totcol; i-- > 0; ) {
253 tmpmesh->mat[i] = tmpmb->mat[i]; /* CRASH HERE ??? */
254 if (tmpmesh->mat[i]) {
255 tmpmb->mat[i]->id.us++;
264 Mesh *origmesh = ob->data;
265 tmpmesh->flag = origmesh->flag;
266 tmpmesh->mat = MEM_dupallocN(origmesh->mat);
267 tmpmesh->totcol = origmesh->totcol;
268 tmpmesh->smoothresh = origmesh->smoothresh;
270 for (i = origmesh->totcol; i-- > 0; ) {
271 /* are we an object material or data based? */
272 tmpmesh->mat[i] = ob->matbits[i] ? ob->mat[i] : origmesh->mat[i];
274 if (tmpmesh->mat[i]) {
275 tmpmesh->mat[i]->id.us++;
281 } /* end copy materials */
283 /* cycles and exporters rely on this still */
284 BKE_mesh_tessface_ensure(tmpmesh);
286 /* we don't assign it to anything */
289 /* make sure materials get updated in objects */
290 test_object_materials(&tmpmesh->id);
295 /* mostly a copy from convertblender.c */
296 static void dupli_render_particle_set(Scene *scene, Object *ob, int level, int enable)
298 /* ugly function, but we need to set particle systems to their render
299 * settings before calling object_duplilist, to get render level duplis */
302 ParticleSystem *psys;
308 if (level >= MAX_DUPLI_RECUR)
311 if (ob->transflag & OB_DUPLIPARTS) {
312 for (psys = ob->particlesystem.first; psys; psys = psys->next) {
313 if (ELEM(psys->part->ren_as, PART_DRAW_OB, PART_DRAW_GR)) {
315 psys_render_set(ob, psys, mat, mat, 1, 1, 0.f);
317 psys_render_restore(ob, psys);
321 if (level == 0 && enable) {
322 /* this is to make sure we get render level duplis in groups:
323 * the derivedmesh must be created before init_render_mesh,
324 * since object_duplilist does dupliparticles before that */
325 dm = mesh_create_derived_render(scene, ob, CD_MASK_BAREMESH | CD_MASK_MTFACE | CD_MASK_MCOL);
328 for (psys = ob->particlesystem.first; psys; psys = psys->next)
329 psys_get_modifier(ob, psys)->flag &= ~eParticleSystemFlag_psys_updated;
333 if (ob->dup_group == NULL) return;
334 group = ob->dup_group;
336 for (go = group->gobject.first; go; go = go->next)
337 dupli_render_particle_set(scene, go->ob, level + 1, enable);
339 /* When no longer needed, duplilist should be freed with Object.free_duplilist */
340 static void rna_Object_create_duplilist(Object *ob, ReportList *reports, Scene *sce)
342 if (!(ob->transflag & OB_DUPLI)) {
343 BKE_report(reports, RPT_ERROR, "Object does not have duplis");
347 /* free duplilist if a user forgets to */
349 BKE_reportf(reports, RPT_WARNING, "Object.dupli_list has not been freed");
351 free_object_duplilist(ob->duplilist);
352 ob->duplilist = NULL;
355 dupli_render_particle_set(sce, ob, 0, 1);
356 ob->duplilist = object_duplilist(sce, ob);
358 dupli_render_particle_set(sce, ob, 0, 0);
359 /* ob->duplilist should now be freed with Object.free_duplilist */
362 static void rna_Object_free_duplilist(Object *ob)
365 free_object_duplilist(ob->duplilist);
366 ob->duplilist = NULL;
370 static PointerRNA rna_Object_shape_key_add(Object *ob, bContext *C, ReportList *reports,
371 const char *name, int from_mix)
373 Scene *scene = CTX_data_scene(C);
376 if ((kb = BKE_object_insert_shape_key(scene, ob, name, from_mix))) {
379 RNA_pointer_create((ID *)ob->data, &RNA_ShapeKey, kb, &keyptr);
380 WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
385 BKE_reportf(reports, RPT_ERROR, "Object \"%s\"does not support shapes", ob->id.name + 2);
386 return PointerRNA_NULL;
390 static int rna_Object_is_visible(Object *ob, Scene *sce)
392 return !(ob->restrictflag & OB_RESTRICT_VIEW) && (ob->lay & sce->lay);
396 static void rna_Mesh_assign_verts_to_group(Object *ob, bDeformGroup *group, int *indices, int totindex,
397 float weight, int assignmode)
399 if (ob->type != OB_MESH) {
400 BKE_report(reports, RPT_ERROR, "Object should be of MESH type");
404 Mesh *me = (Mesh *)ob->data;
405 int group_index = BLI_findlink(&ob->defbase, group);
406 if (group_index == -1) {
407 BKE_report(reports, RPT_ERROR, "No deform groups assigned to mesh");
411 if (assignmode != WEIGHT_REPLACE && assignmode != WEIGHT_ADD && assignmode != WEIGHT_SUBTRACT) {
412 BKE_report(reports, RPT_ERROR, "Bad assignment mode");
416 /* makes a set of dVerts corresponding to the mVerts */
418 create_dverts(&me->id);
420 /* loop list adding verts to group */
421 for (i = 0; i < totindex; i++) {
422 if (i < 0 || i >= me->totvert) {
423 BKE_report(reports, RPT_ERROR, "Bad vertex index in list");
427 add_vert_defnr(ob, group_index, i, weight, assignmode);
432 /* BMESH_TODO, return polygon index, not tessface */
433 static void rna_Object_ray_cast(Object *ob, ReportList *reports, float ray_start[3], float ray_end[3],
434 float r_location[3], float r_normal[3], int *index)
436 BVHTreeFromMesh treeData = {NULL};
438 if (ob->derivedFinal == NULL) {
439 BKE_reportf(reports, RPT_ERROR, "object \"%s\" has no mesh data to be used for ray casting", ob->id.name + 2);
443 /* no need to managing allocation or freeing of the BVH data. this is generated and freed as needed */
444 bvhtree_from_mesh_faces(&treeData, ob->derivedFinal, 0.0f, 4, 6);
446 if (treeData.tree == NULL) {
447 BKE_reportf(reports, RPT_ERROR, "object \"%s\" could not create internal data for ray casting", ob->id.name + 2);
452 float ray_nor[3], dist;
453 sub_v3_v3v3(ray_nor, ray_end, ray_start);
455 dist = hit.dist = normalize_v3(ray_nor);
458 if (BLI_bvhtree_ray_cast(treeData.tree, ray_start, ray_nor, 0.0f, &hit,
459 treeData.raycast_callback, &treeData) != -1)
461 if (hit.dist <= dist) {
462 copy_v3_v3(r_location, hit.co);
463 copy_v3_v3(r_normal, hit.no);
475 static void rna_Object_closest_point_on_mesh(Object *ob, ReportList *reports, float point_co[3], float max_dist,
476 float n_location[3], float n_normal[3], int *index)
478 BVHTreeFromMesh treeData = {NULL};
480 if (ob->derivedFinal == NULL) {
481 BKE_reportf(reports, RPT_ERROR, "object \"%s\" has no mesh data to be used for finding nearest point",
486 /* no need to managing allocation or freeing of the BVH data. this is generated and freed as needed */
487 bvhtree_from_mesh_faces(&treeData, ob->derivedFinal, 0.0f, 4, 6);
489 if (treeData.tree == NULL) {
490 BKE_reportf(reports, RPT_ERROR, "object \"%s\" could not create internal data for finding nearest point",
495 BVHTreeNearest nearest;
498 nearest.dist = max_dist * max_dist;
500 if (BLI_bvhtree_find_nearest(treeData.tree, point_co, &nearest, treeData.nearest_callback, &treeData) != -1) {
501 copy_v3_v3(n_location, nearest.co);
502 copy_v3_v3(n_normal, nearest.no);
503 *index = nearest.index;
515 static void rna_ObjectBase_layers_from_view(Base *base, View3D *v3d)
517 base->lay = base->object->lay = v3d->lay;
520 static int rna_Object_is_modified(Object *ob, Scene *scene, int settings)
522 return BKE_object_is_modified(scene, ob) & settings;
525 static int rna_Object_is_deform_modified(Object *ob, Scene *scene, int settings)
527 return BKE_object_is_deform_modified(scene, ob) & settings;
531 void rna_Object_dm_info(struct Object *ob, int type, char *result)
533 DerivedMesh *dm = NULL;
534 int dm_release = FALSE;
541 if (ob->type == OB_MESH) {
542 dm = CDDM_from_mesh(ob->data, ob);
543 ret = DM_debug_info(dm);
548 dm = ob->derivedDeform;
551 dm = ob->derivedFinal;
556 ret = DM_debug_info(dm);
570 void RNA_api_object(StructRNA *srna)
575 static EnumPropertyItem mesh_type_items[] = {
576 {eModifierMode_Realtime, "PREVIEW", 0, "Preview", "Apply modifier preview settings"},
577 {eModifierMode_Render, "RENDER", 0, "Render", "Apply modifier render settings"},
578 {0, NULL, 0, NULL, NULL}
582 static EnumPropertyItem mesh_dm_info_items[] = {
583 {0, "SOURCE", 0, "Source", "Source mesh"},
584 {1, "DEFORM", 0, "Deform", "Objects deform mesh"},
585 {2, "FINAL", 0, "Final", "Objects final mesh"},
586 {0, NULL, 0, NULL, NULL}
591 func = RNA_def_function(srna, "to_mesh", "rna_Object_to_mesh");
592 RNA_def_function_ui_description(func, "Create a Mesh datablock with modifiers applied");
593 RNA_def_function_flag(func, FUNC_USE_REPORTS);
594 parm = RNA_def_pointer(func, "scene", "Scene", "", "Scene within which to evaluate modifiers");
595 RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
596 parm = RNA_def_boolean(func, "apply_modifiers", 0, "", "Apply modifiers");
597 RNA_def_property_flag(parm, PROP_REQUIRED);
598 parm = RNA_def_enum(func, "settings", mesh_type_items, 0, "", "Modifier settings to apply");
599 RNA_def_property_flag(parm, PROP_REQUIRED);
600 parm = RNA_def_pointer(func, "mesh", "Mesh", "",
601 "Mesh created from object, remove it if it is only used for export");
602 RNA_def_function_return(func, parm);
605 func = RNA_def_function(srna, "dupli_list_create", "rna_Object_create_duplilist");
606 RNA_def_function_ui_description(func, "Create a list of dupli objects for this object, needs to "
607 "be freed manually with free_dupli_list to restore the "
608 "objects real matrix and layers");
609 parm = RNA_def_pointer(func, "scene", "Scene", "", "Scene within which to evaluate duplis");
610 RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
611 RNA_def_function_flag(func, FUNC_USE_REPORTS);
613 func = RNA_def_function(srna, "dupli_list_clear", "rna_Object_free_duplilist");
614 RNA_def_function_ui_description(func, "Free the list of dupli objects");
617 func = RNA_def_function(srna, "find_armature", "modifiers_isDeformedByArmature");
618 RNA_def_function_ui_description(func, "Find armature influencing this object as a parent or via a modifier");
619 parm = RNA_def_pointer(func, "ob_arm", "Object", "", "Armature object influencing this object or NULL");
620 RNA_def_function_return(func, parm);
623 func = RNA_def_function(srna, "shape_key_add", "rna_Object_shape_key_add");
624 RNA_def_function_ui_description(func, "Add shape key to an object");
625 RNA_def_function_flag(func, FUNC_USE_CONTEXT | FUNC_USE_REPORTS);
626 RNA_def_string(func, "name", "Key", 0, "", "Unique name for the new keylock"); /* optional */
627 RNA_def_boolean(func, "from_mix", 1, "", "Create new shape from existing mix of shapes");
628 parm = RNA_def_pointer(func, "key", "ShapeKey", "", "New shape keyblock");
629 RNA_def_property_flag(parm, PROP_RNAPTR);
630 RNA_def_function_return(func, parm);
633 func = RNA_def_function(srna, "ray_cast", "rna_Object_ray_cast");
634 RNA_def_function_ui_description(func, "Cast a ray onto in object space");
635 RNA_def_function_flag(func, FUNC_USE_REPORTS);
637 /* ray start and end */
638 parm = RNA_def_float_vector(func, "start", 3, NULL, -FLT_MAX, FLT_MAX, "", "", -1e4, 1e4);
639 RNA_def_property_flag(parm, PROP_REQUIRED);
640 parm = RNA_def_float_vector(func, "end", 3, NULL, -FLT_MAX, FLT_MAX, "", "", -1e4, 1e4);
641 RNA_def_property_flag(parm, PROP_REQUIRED);
643 /* return location and normal */
644 parm = RNA_def_float_vector(func, "location", 3, NULL, -FLT_MAX, FLT_MAX, "Location",
645 "The hit location of this ray cast", -1e4, 1e4);
646 RNA_def_property_flag(parm, PROP_THICK_WRAP);
647 RNA_def_function_output(func, parm);
648 parm = RNA_def_float_vector(func, "normal", 3, NULL, -FLT_MAX, FLT_MAX, "Normal",
649 "The face normal at the ray cast hit location", -1e4, 1e4);
650 RNA_def_property_flag(parm, PROP_THICK_WRAP);
651 RNA_def_function_output(func, parm);
653 parm = RNA_def_int(func, "index", 0, 0, 0, "", "The face index, -1 when no intersection is found", 0, 0);
654 RNA_def_function_output(func, parm);
657 func = RNA_def_function(srna, "closest_point_on_mesh", "rna_Object_closest_point_on_mesh");
658 RNA_def_function_ui_description(func, "Find the nearest point on the object");
659 RNA_def_function_flag(func, FUNC_USE_REPORTS);
661 /* location of point for test and max distance */
662 parm = RNA_def_float_vector(func, "point", 3, NULL, -FLT_MAX, FLT_MAX, "", "", -1e4, 1e4);
663 RNA_def_property_flag(parm, PROP_REQUIRED);
664 /* default is sqrt(FLT_MAX) */
665 RNA_def_float(func, "max_dist", 1.844674352395373e+19, 0.0, FLT_MAX, "", "", 0.0, FLT_MAX);
667 /* return location and normal */
668 parm = RNA_def_float_vector(func, "location", 3, NULL, -FLT_MAX, FLT_MAX, "Location",
669 "The location on the object closest to the point", -1e4, 1e4);
670 RNA_def_property_flag(parm, PROP_THICK_WRAP);
671 RNA_def_function_output(func, parm);
672 parm = RNA_def_float_vector(func, "normal", 3, NULL, -FLT_MAX, FLT_MAX, "Normal",
673 "The face normal at the closest point", -1e4, 1e4);
674 RNA_def_property_flag(parm, PROP_THICK_WRAP);
675 RNA_def_function_output(func, parm);
677 parm = RNA_def_int(func, "index", 0, 0, 0, "", "The face index, -1 when no closest point is found", 0, 0);
678 RNA_def_function_output(func, parm);
681 func = RNA_def_function(srna, "is_visible", "rna_Object_is_visible");
682 RNA_def_function_ui_description(func, "Determine if object is visible in a given scene");
683 parm = RNA_def_pointer(func, "scene", "Scene", "", "");
684 RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
685 parm = RNA_def_boolean(func, "result", 0, "", "Object visibility");
686 RNA_def_function_return(func, parm);
688 /* utility function for checking if the object is modified */
689 func = RNA_def_function(srna, "is_modified", "rna_Object_is_modified");
690 RNA_def_function_ui_description(func, "Determine if this object is modified from the base mesh data");
691 parm = RNA_def_pointer(func, "scene", "Scene", "", "");
692 RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
693 parm = RNA_def_enum(func, "settings", mesh_type_items, 0, "", "Modifier settings to apply");
694 RNA_def_property_flag(parm, PROP_REQUIRED);
695 parm = RNA_def_boolean(func, "result", 0, "", "Object visibility");
696 RNA_def_function_return(func, parm);
698 func = RNA_def_function(srna, "is_deform_modified", "rna_Object_is_deform_modified");
699 RNA_def_function_ui_description(func, "Determine if this object is modified by a deformation from the base mesh data");
700 parm = RNA_def_pointer(func, "scene", "Scene", "", "");
701 RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
702 parm = RNA_def_enum(func, "settings", mesh_type_items, 0, "", "Modifier settings to apply");
703 RNA_def_property_flag(parm, PROP_REQUIRED);
704 parm = RNA_def_boolean(func, "result", 0, "", "Object visibility");
705 RNA_def_function_return(func, parm);
709 func = RNA_def_function(srna, "dm_info", "rna_Object_dm_info");
710 RNA_def_function_ui_description(func, "Returns a string for derived mesh data");
712 parm = RNA_def_enum(func, "type", mesh_dm_info_items, 0, "", "Modifier settings to apply");
713 RNA_def_property_flag(parm, PROP_REQUIRED);
714 /* weak!, no way to return dynamic string type */
715 parm = RNA_def_string(func, "result", "", 16384, "result", "");
716 RNA_def_property_flag(parm, PROP_THICK_WRAP); /* needed for string return value */
717 RNA_def_function_output(func, parm);
722 void RNA_api_object_base(StructRNA *srna)
727 func = RNA_def_function(srna, "layers_from_view", "rna_ObjectBase_layers_from_view");
728 RNA_def_function_ui_description(func,
729 "Sets the object layers from a 3D View (use when adding an object in local view)");
730 parm = RNA_def_pointer(func, "view", "SpaceView3D", "", "");
731 RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);