1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2009 Blender Foundation.
17  * All rights reserved.
18  */
19 
20 /** \file
21  * \ingroup RNA
22  */
23 
24 #include <errno.h>
25 #include <stdio.h>
26 #include <stdlib.h>
27 
28 #include "DNA_ID.h"
29 #include "DNA_modifier_types.h"
30 #include "DNA_object_types.h"
31 #include "DNA_space_types.h"
32 
33 #include "BLI_utildefines.h"
34 
35 #include "RNA_access.h"
36 #include "RNA_define.h"
37 #include "RNA_enum_types.h"
38 
39 #include "rna_internal.h"
40 
41 #ifdef RNA_RUNTIME
42 
43 #  include "BKE_action.h"
44 #  include "BKE_armature.h"
45 #  include "BKE_brush.h"
46 #  include "BKE_camera.h"
47 #  include "BKE_collection.h"
48 #  include "BKE_curve.h"
49 #  include "BKE_displist.h"
50 #  include "BKE_font.h"
51 #  include "BKE_gpencil.h"
52 #  include "BKE_hair.h"
53 #  include "BKE_icons.h"
54 #  include "BKE_idtype.h"
55 #  include "BKE_image.h"
56 #  include "BKE_lattice.h"
57 #  include "BKE_lib_remap.h"
58 #  include "BKE_light.h"
59 #  include "BKE_lightprobe.h"
60 #  include "BKE_linestyle.h"
61 #  include "BKE_mask.h"
62 #  include "BKE_material.h"
63 #  include "BKE_mball.h"
64 #  include "BKE_mesh.h"
65 #  include "BKE_movieclip.h"
66 #  include "BKE_node.h"
67 #  include "BKE_object.h"
68 #  include "BKE_paint.h"
69 #  include "BKE_particle.h"
70 #  include "BKE_pointcloud.h"
71 #  include "BKE_scene.h"
72 #  include "BKE_simulation.h"
73 #  include "BKE_sound.h"
74 #  include "BKE_speaker.h"
75 #  include "BKE_text.h"
76 #  include "BKE_texture.h"
77 #  include "BKE_volume.h"
78 #  include "BKE_workspace.h"
79 #  include "BKE_world.h"
80 
81 #  include "DEG_depsgraph_build.h"
82 #  include "DEG_depsgraph_query.h"
83 
84 #  include "DNA_armature_types.h"
85 #  include "DNA_brush_types.h"
86 #  include "DNA_camera_types.h"
87 #  include "DNA_collection_types.h"
88 #  include "DNA_curve_types.h"
89 #  include "DNA_gpencil_types.h"
90 #  include "DNA_hair_types.h"
91 #  include "DNA_lattice_types.h"
92 #  include "DNA_light_types.h"
93 #  include "DNA_lightprobe_types.h"
94 #  include "DNA_mask_types.h"
95 #  include "DNA_material_types.h"
96 #  include "DNA_mesh_types.h"
97 #  include "DNA_meta_types.h"
98 #  include "DNA_movieclip_types.h"
99 #  include "DNA_node_types.h"
100 #  include "DNA_particle_types.h"
101 #  include "DNA_pointcloud_types.h"
102 #  include "DNA_simulation_types.h"
103 #  include "DNA_sound_types.h"
104 #  include "DNA_speaker_types.h"
105 #  include "DNA_text_types.h"
106 #  include "DNA_texture_types.h"
107 #  include "DNA_vfont_types.h"
108 #  include "DNA_volume_types.h"
109 #  include "DNA_world_types.h"
110 
111 #  include "ED_screen.h"
112 
113 #  include "BLT_translation.h"
114 
115 #  ifdef WITH_PYTHON
116 #    include "BPY_extern.h"
117 #  endif
118 
119 #  include "WM_api.h"
120 #  include "WM_types.h"
121 
rna_idname_validate(const char * name,char * r_name)122 static void rna_idname_validate(const char *name, char *r_name)
123 {
124   BLI_strncpy(r_name, name, MAX_ID_NAME - 2);
125   BLI_utf8_invalid_strip(r_name, strlen(r_name));
126 }
127 
rna_Main_ID_remove(Main * bmain,ReportList * reports,PointerRNA * id_ptr,bool do_unlink,bool do_id_user,bool do_ui_user)128 static void rna_Main_ID_remove(Main *bmain,
129                                ReportList *reports,
130                                PointerRNA *id_ptr,
131                                bool do_unlink,
132                                bool do_id_user,
133                                bool do_ui_user)
134 {
135   ID *id = id_ptr->data;
136   if (id->tag & LIB_TAG_NO_MAIN) {
137     BKE_reportf(reports,
138                 RPT_ERROR,
139                 "%s '%s' is outside of main database and can not be removed from it",
140                 BKE_idtype_idcode_to_name(GS(id->name)),
141                 id->name + 2);
142     return;
143   }
144   if (do_unlink) {
145     BKE_id_delete(bmain, id);
146     RNA_POINTER_INVALIDATE(id_ptr);
147     /* Force full redraw, mandatory to avoid crashes when running this from UI... */
148     WM_main_add_notifier(NC_WINDOW, NULL);
149   }
150   else if (ID_REAL_USERS(id) <= 0) {
151     const int flag = (do_id_user ? 0 : LIB_ID_FREE_NO_USER_REFCOUNT) |
152                      (do_ui_user ? 0 : LIB_ID_FREE_NO_UI_USER);
153     /* Still using ID flags here, this is in-between commit anyway... */
154     BKE_id_free_ex(bmain, id, flag, true);
155     RNA_POINTER_INVALIDATE(id_ptr);
156   }
157   else {
158     BKE_reportf(
159         reports,
160         RPT_ERROR,
161         "%s '%s' must have zero users to be removed, found %d (try with do_unlink=True parameter)",
162         BKE_idtype_idcode_to_name(GS(id->name)),
163         id->name + 2,
164         ID_REAL_USERS(id));
165   }
166 }
167 
rna_Main_cameras_new(Main * bmain,const char * name)168 static Camera *rna_Main_cameras_new(Main *bmain, const char *name)
169 {
170   char safe_name[MAX_ID_NAME - 2];
171   rna_idname_validate(name, safe_name);
172 
173   ID *id = BKE_camera_add(bmain, safe_name);
174   id_us_min(id);
175   return (Camera *)id;
176 }
177 
rna_Main_scenes_new(Main * bmain,const char * name)178 static Scene *rna_Main_scenes_new(Main *bmain, const char *name)
179 {
180   char safe_name[MAX_ID_NAME - 2];
181   rna_idname_validate(name, safe_name);
182 
183   return BKE_scene_add(bmain, safe_name);
184 }
rna_Main_scenes_remove(Main * bmain,bContext * C,ReportList * reports,PointerRNA * scene_ptr,bool do_unlink)185 static void rna_Main_scenes_remove(
186     Main *bmain, bContext *C, ReportList *reports, PointerRNA *scene_ptr, bool do_unlink)
187 {
188   /* don't call BKE_id_free(...) directly */
189   Scene *scene = scene_ptr->data;
190   Scene *scene_new;
191 
192   if ((scene_new = scene->id.prev) || (scene_new = scene->id.next)) {
193     if (do_unlink) {
194       wmWindow *win = CTX_wm_window(C);
195 
196       if (WM_window_get_active_scene(win) == scene) {
197 
198 #  ifdef WITH_PYTHON
199         BPy_BEGIN_ALLOW_THREADS;
200 #  endif
201 
202         WM_window_set_active_scene(bmain, C, win, scene_new);
203 
204 #  ifdef WITH_PYTHON
205         BPy_END_ALLOW_THREADS;
206 #  endif
207       }
208     }
209     rna_Main_ID_remove(bmain, reports, scene_ptr, do_unlink, true, true);
210   }
211   else {
212     BKE_reportf(
213         reports, RPT_ERROR, "Scene '%s' is the last, cannot be removed", scene->id.name + 2);
214   }
215 }
216 
rna_Main_objects_new(Main * bmain,ReportList * reports,const char * name,ID * data)217 static Object *rna_Main_objects_new(Main *bmain, ReportList *reports, const char *name, ID *data)
218 {
219   if (data != NULL && (data->tag & LIB_TAG_NO_MAIN)) {
220     BKE_report(reports,
221                RPT_ERROR,
222                "Can not create object in main database with an evaluated data data-block");
223     return NULL;
224   }
225 
226   char safe_name[MAX_ID_NAME - 2];
227   rna_idname_validate(name, safe_name);
228 
229   Object *ob;
230   int type = OB_EMPTY;
231 
232   if (data) {
233     type = BKE_object_obdata_to_type(data);
234     if (type == -1) {
235       const char *idname;
236       if (RNA_enum_id_from_value(rna_enum_id_type_items, GS(data->name), &idname) == 0) {
237         idname = "UNKNOWN";
238       }
239 
240       BKE_reportf(reports, RPT_ERROR, "ID type '%s' is not valid for an object", idname);
241       return NULL;
242     }
243 
244     id_us_plus(data);
245   }
246 
247   ob = BKE_object_add_only_object(bmain, type, safe_name);
248 
249   ob->data = data;
250   BKE_object_materials_test(bmain, ob, ob->data);
251 
252   return ob;
253 }
254 
rna_Main_materials_new(Main * bmain,const char * name)255 static Material *rna_Main_materials_new(Main *bmain, const char *name)
256 {
257   char safe_name[MAX_ID_NAME - 2];
258   rna_idname_validate(name, safe_name);
259 
260   ID *id = (ID *)BKE_material_add(bmain, safe_name);
261   id_us_min(id);
262   return (Material *)id;
263 }
264 
rna_Main_materials_gpencil_data(Main * UNUSED (bmain),PointerRNA * id_ptr)265 static void rna_Main_materials_gpencil_data(Main *UNUSED(bmain), PointerRNA *id_ptr)
266 {
267   ID *id = id_ptr->data;
268   Material *ma = (Material *)id;
269   BKE_gpencil_material_attr_init(ma);
270 }
271 
rna_Main_materials_gpencil_remove(Main * UNUSED (bmain),PointerRNA * id_ptr)272 static void rna_Main_materials_gpencil_remove(Main *UNUSED(bmain), PointerRNA *id_ptr)
273 {
274   ID *id = id_ptr->data;
275   Material *ma = (Material *)id;
276   if (ma->gp_style) {
277     MEM_SAFE_FREE(ma->gp_style);
278   }
279 }
280 
rna_Main_nodetree_type_itemf(bContext * UNUSED (C),PointerRNA * UNUSED (ptr),PropertyRNA * UNUSED (prop),bool * r_free)281 static const EnumPropertyItem *rna_Main_nodetree_type_itemf(bContext *UNUSED(C),
282                                                             PointerRNA *UNUSED(ptr),
283                                                             PropertyRNA *UNUSED(prop),
284                                                             bool *r_free)
285 {
286   return rna_node_tree_type_itemf(NULL, NULL, r_free);
287 }
rna_Main_nodetree_new(Main * bmain,const char * name,int type)288 static struct bNodeTree *rna_Main_nodetree_new(Main *bmain, const char *name, int type)
289 {
290   char safe_name[MAX_ID_NAME - 2];
291   rna_idname_validate(name, safe_name);
292 
293   bNodeTreeType *typeinfo = rna_node_tree_type_from_enum(type);
294   if (typeinfo) {
295     bNodeTree *ntree = ntreeAddTree(bmain, safe_name, typeinfo->idname);
296 
297     id_us_min(&ntree->id);
298     return ntree;
299   }
300   else {
301     return NULL;
302   }
303 }
304 
rna_Main_meshes_new(Main * bmain,const char * name)305 static Mesh *rna_Main_meshes_new(Main *bmain, const char *name)
306 {
307   char safe_name[MAX_ID_NAME - 2];
308   rna_idname_validate(name, safe_name);
309 
310   Mesh *me = BKE_mesh_add(bmain, safe_name);
311   id_us_min(&me->id);
312   return me;
313 }
314 
315 /* copied from Mesh_getFromObject and adapted to RNA interface */
rna_Main_meshes_new_from_object(Main * bmain,ReportList * reports,Object * object,bool preserve_all_data_layers,Depsgraph * depsgraph)316 static Mesh *rna_Main_meshes_new_from_object(Main *bmain,
317                                              ReportList *reports,
318                                              Object *object,
319                                              bool preserve_all_data_layers,
320                                              Depsgraph *depsgraph)
321 {
322   switch (object->type) {
323     case OB_FONT:
324     case OB_CURVE:
325     case OB_SURF:
326     case OB_MBALL:
327     case OB_MESH:
328       break;
329     default:
330       BKE_report(reports, RPT_ERROR, "Object does not have geometry data");
331       return NULL;
332   }
333 
334   return BKE_mesh_new_from_object_to_bmain(bmain, depsgraph, object, preserve_all_data_layers);
335 }
336 
rna_Main_lights_new(Main * bmain,const char * name,int type)337 static Light *rna_Main_lights_new(Main *bmain, const char *name, int type)
338 {
339   char safe_name[MAX_ID_NAME - 2];
340   rna_idname_validate(name, safe_name);
341 
342   Light *lamp = BKE_light_add(bmain, safe_name);
343   lamp->type = type;
344   id_us_min(&lamp->id);
345   return lamp;
346 }
347 
rna_Main_images_new(Main * bmain,const char * name,int width,int height,bool alpha,bool float_buffer,bool stereo3d,bool is_data,bool tiled)348 static Image *rna_Main_images_new(Main *bmain,
349                                   const char *name,
350                                   int width,
351                                   int height,
352                                   bool alpha,
353                                   bool float_buffer,
354                                   bool stereo3d,
355                                   bool is_data,
356                                   bool tiled)
357 {
358   char safe_name[MAX_ID_NAME - 2];
359   rna_idname_validate(name, safe_name);
360 
361   float color[4] = {0.0, 0.0, 0.0, 1.0};
362   Image *image = BKE_image_add_generated(bmain,
363                                          width,
364                                          height,
365                                          safe_name,
366                                          alpha ? 32 : 24,
367                                          float_buffer,
368                                          0,
369                                          color,
370                                          stereo3d,
371                                          is_data,
372                                          tiled);
373   id_us_min(&image->id);
374   return image;
375 }
rna_Main_images_load(Main * bmain,ReportList * reports,const char * filepath,bool check_existing)376 static Image *rna_Main_images_load(Main *bmain,
377                                    ReportList *reports,
378                                    const char *filepath,
379                                    bool check_existing)
380 {
381   Image *ima;
382 
383   errno = 0;
384   if (check_existing) {
385     ima = BKE_image_load_exists(bmain, filepath);
386   }
387   else {
388     ima = BKE_image_load(bmain, filepath);
389   }
390 
391   if (!ima) {
392     BKE_reportf(reports,
393                 RPT_ERROR,
394                 "Cannot read '%s': %s",
395                 filepath,
396                 errno ? strerror(errno) : TIP_("unsupported image format"));
397   }
398 
399   id_us_min((ID *)ima);
400   return ima;
401 }
402 
rna_Main_lattices_new(Main * bmain,const char * name)403 static Lattice *rna_Main_lattices_new(Main *bmain, const char *name)
404 {
405   char safe_name[MAX_ID_NAME - 2];
406   rna_idname_validate(name, safe_name);
407 
408   Lattice *lt = BKE_lattice_add(bmain, safe_name);
409   id_us_min(&lt->id);
410   return lt;
411 }
412 
rna_Main_curves_new(Main * bmain,const char * name,int type)413 static Curve *rna_Main_curves_new(Main *bmain, const char *name, int type)
414 {
415   char safe_name[MAX_ID_NAME - 2];
416   rna_idname_validate(name, safe_name);
417 
418   Curve *cu = BKE_curve_add(bmain, safe_name, type);
419   id_us_min(&cu->id);
420   return cu;
421 }
422 
rna_Main_metaballs_new(Main * bmain,const char * name)423 static MetaBall *rna_Main_metaballs_new(Main *bmain, const char *name)
424 {
425   char safe_name[MAX_ID_NAME - 2];
426   rna_idname_validate(name, safe_name);
427 
428   MetaBall *mb = BKE_mball_add(bmain, safe_name);
429   id_us_min(&mb->id);
430   return mb;
431 }
432 
rna_Main_fonts_load(Main * bmain,ReportList * reports,const char * filepath,bool check_existing)433 static VFont *rna_Main_fonts_load(Main *bmain,
434                                   ReportList *reports,
435                                   const char *filepath,
436                                   bool check_existing)
437 {
438   VFont *font;
439   errno = 0;
440 
441   if (check_existing) {
442     font = BKE_vfont_load_exists(bmain, filepath);
443   }
444   else {
445     font = BKE_vfont_load(bmain, filepath);
446   }
447 
448   if (!font) {
449     BKE_reportf(reports,
450                 RPT_ERROR,
451                 "Cannot read '%s': %s",
452                 filepath,
453                 errno ? strerror(errno) : TIP_("unsupported font format"));
454   }
455   return font;
456 }
457 
rna_Main_textures_new(Main * bmain,const char * name,int type)458 static Tex *rna_Main_textures_new(Main *bmain, const char *name, int type)
459 {
460   char safe_name[MAX_ID_NAME - 2];
461   rna_idname_validate(name, safe_name);
462 
463   Tex *tex = BKE_texture_add(bmain, safe_name);
464   BKE_texture_type_set(tex, type);
465   id_us_min(&tex->id);
466   return tex;
467 }
468 
rna_Main_brushes_new(Main * bmain,const char * name,int mode)469 static Brush *rna_Main_brushes_new(Main *bmain, const char *name, int mode)
470 {
471   char safe_name[MAX_ID_NAME - 2];
472   rna_idname_validate(name, safe_name);
473 
474   Brush *brush = BKE_brush_add(bmain, safe_name, mode);
475   id_us_min(&brush->id);
476   return brush;
477 }
478 
rna_Main_brush_gpencil_data(Main * UNUSED (bmain),PointerRNA * id_ptr)479 static void rna_Main_brush_gpencil_data(Main *UNUSED(bmain), PointerRNA *id_ptr)
480 {
481   ID *id = id_ptr->data;
482   Brush *brush = (Brush *)id;
483   BKE_brush_init_gpencil_settings(brush);
484 }
485 
rna_Main_worlds_new(Main * bmain,const char * name)486 static World *rna_Main_worlds_new(Main *bmain, const char *name)
487 {
488   char safe_name[MAX_ID_NAME - 2];
489   rna_idname_validate(name, safe_name);
490 
491   World *world = BKE_world_add(bmain, safe_name);
492   id_us_min(&world->id);
493   return world;
494 }
495 
rna_Main_collections_new(Main * bmain,const char * name)496 static Collection *rna_Main_collections_new(Main *bmain, const char *name)
497 {
498   char safe_name[MAX_ID_NAME - 2];
499   rna_idname_validate(name, safe_name);
500 
501   return BKE_collection_add(bmain, NULL, safe_name);
502 }
503 
rna_Main_speakers_new(Main * bmain,const char * name)504 static Speaker *rna_Main_speakers_new(Main *bmain, const char *name)
505 {
506   char safe_name[MAX_ID_NAME - 2];
507   rna_idname_validate(name, safe_name);
508 
509   Speaker *speaker = BKE_speaker_add(bmain, safe_name);
510   id_us_min(&speaker->id);
511   return speaker;
512 }
513 
rna_Main_sounds_load(Main * bmain,const char * name,bool check_existing)514 static bSound *rna_Main_sounds_load(Main *bmain, const char *name, bool check_existing)
515 {
516   bSound *sound;
517 
518   if (check_existing) {
519     sound = BKE_sound_new_file_exists(bmain, name);
520   }
521   else {
522     sound = BKE_sound_new_file(bmain, name);
523   }
524 
525   id_us_min(&sound->id);
526   return sound;
527 }
528 
rna_Main_texts_new(Main * bmain,const char * name)529 static Text *rna_Main_texts_new(Main *bmain, const char *name)
530 {
531   char safe_name[MAX_ID_NAME - 2];
532   rna_idname_validate(name, safe_name);
533 
534   return BKE_text_add(bmain, safe_name);
535 }
536 
rna_Main_texts_load(Main * bmain,ReportList * reports,const char * filepath,bool is_internal)537 static Text *rna_Main_texts_load(Main *bmain,
538                                  ReportList *reports,
539                                  const char *filepath,
540                                  bool is_internal)
541 {
542   Text *txt;
543 
544   errno = 0;
545   txt = BKE_text_load_ex(bmain, filepath, BKE_main_blendfile_path(bmain), is_internal);
546   /* Texts have no user by default... Only the 'real' user flag. */
547   id_us_min(&txt->id);
548 
549   if (!txt) {
550     BKE_reportf(reports,
551                 RPT_ERROR,
552                 "Cannot read '%s': %s",
553                 filepath,
554                 errno ? strerror(errno) : TIP_("unable to load text"));
555   }
556   return txt;
557 }
558 
rna_Main_armatures_new(Main * bmain,const char * name)559 static bArmature *rna_Main_armatures_new(Main *bmain, const char *name)
560 {
561   char safe_name[MAX_ID_NAME - 2];
562   rna_idname_validate(name, safe_name);
563 
564   bArmature *arm = BKE_armature_add(bmain, safe_name);
565   id_us_min(&arm->id);
566   return arm;
567 }
568 
rna_Main_actions_new(Main * bmain,const char * name)569 static bAction *rna_Main_actions_new(Main *bmain, const char *name)
570 {
571   char safe_name[MAX_ID_NAME - 2];
572   rna_idname_validate(name, safe_name);
573 
574   bAction *act = BKE_action_add(bmain, safe_name);
575   id_fake_user_clear(&act->id);
576   return act;
577 }
578 
rna_Main_particles_new(Main * bmain,const char * name)579 static ParticleSettings *rna_Main_particles_new(Main *bmain, const char *name)
580 {
581   char safe_name[MAX_ID_NAME - 2];
582   rna_idname_validate(name, safe_name);
583 
584   ParticleSettings *part = BKE_particlesettings_add(bmain, safe_name);
585   id_us_min(&part->id);
586   return part;
587 }
588 
rna_Main_palettes_new(Main * bmain,const char * name)589 static Palette *rna_Main_palettes_new(Main *bmain, const char *name)
590 {
591   char safe_name[MAX_ID_NAME - 2];
592   rna_idname_validate(name, safe_name);
593 
594   Palette *palette = BKE_palette_add(bmain, safe_name);
595   id_us_min(&palette->id);
596   return (Palette *)palette;
597 }
598 
rna_Main_movieclip_load(Main * bmain,ReportList * reports,const char * filepath,bool check_existing)599 static MovieClip *rna_Main_movieclip_load(Main *bmain,
600                                           ReportList *reports,
601                                           const char *filepath,
602                                           bool check_existing)
603 {
604   MovieClip *clip;
605 
606   errno = 0;
607 
608   if (check_existing) {
609     clip = BKE_movieclip_file_add_exists(bmain, filepath);
610   }
611   else {
612     clip = BKE_movieclip_file_add(bmain, filepath);
613   }
614 
615   if (clip != NULL) {
616     DEG_relations_tag_update(bmain);
617   }
618   else {
619     BKE_reportf(reports,
620                 RPT_ERROR,
621                 "Cannot read '%s': %s",
622                 filepath,
623                 errno ? strerror(errno) : TIP_("unable to load movie clip"));
624   }
625 
626   id_us_min((ID *)clip);
627   return clip;
628 }
629 
rna_Main_mask_new(Main * bmain,const char * name)630 static Mask *rna_Main_mask_new(Main *bmain, const char *name)
631 {
632   char safe_name[MAX_ID_NAME - 2];
633   rna_idname_validate(name, safe_name);
634 
635   return BKE_mask_new(bmain, safe_name);
636 }
637 
rna_Main_linestyles_new(Main * bmain,const char * name)638 static FreestyleLineStyle *rna_Main_linestyles_new(Main *bmain, const char *name)
639 {
640   char safe_name[MAX_ID_NAME - 2];
641   rna_idname_validate(name, safe_name);
642 
643   FreestyleLineStyle *linestyle = BKE_linestyle_new(bmain, safe_name);
644   id_us_min(&linestyle->id);
645   return linestyle;
646 }
647 
rna_Main_lightprobe_new(Main * bmain,const char * name,int type)648 static LightProbe *rna_Main_lightprobe_new(Main *bmain, const char *name, int type)
649 {
650   char safe_name[MAX_ID_NAME - 2];
651   rna_idname_validate(name, safe_name);
652 
653   LightProbe *probe = BKE_lightprobe_add(bmain, safe_name);
654 
655   BKE_lightprobe_type_set(probe, type);
656 
657   id_us_min(&probe->id);
658   return probe;
659 }
660 
rna_Main_gpencils_new(Main * bmain,const char * name)661 static bGPdata *rna_Main_gpencils_new(Main *bmain, const char *name)
662 {
663   char safe_name[MAX_ID_NAME - 2];
664   rna_idname_validate(name, safe_name);
665 
666   bGPdata *gpd = BKE_gpencil_data_addnew(bmain, safe_name);
667   id_us_min(&gpd->id);
668   return gpd;
669 }
670 
671 #  ifdef WITH_HAIR_NODES
rna_Main_hairs_new(Main * bmain,const char * name)672 static Hair *rna_Main_hairs_new(Main *bmain, const char *name)
673 {
674   char safe_name[MAX_ID_NAME - 2];
675   rna_idname_validate(name, safe_name);
676 
677   Hair *hair = BKE_hair_add(bmain, safe_name);
678   id_us_min(&hair->id);
679   return hair;
680 }
681 #  endif
682 
683 #  ifdef WITH_POINT_CLOUD
rna_Main_pointclouds_new(Main * bmain,const char * name)684 static PointCloud *rna_Main_pointclouds_new(Main *bmain, const char *name)
685 {
686   char safe_name[MAX_ID_NAME - 2];
687   rna_idname_validate(name, safe_name);
688 
689   PointCloud *pointcloud = BKE_pointcloud_add(bmain, safe_name);
690   id_us_min(&pointcloud->id);
691   return pointcloud;
692 }
693 #  endif
694 
rna_Main_volumes_new(Main * bmain,const char * name)695 static Volume *rna_Main_volumes_new(Main *bmain, const char *name)
696 {
697   char safe_name[MAX_ID_NAME - 2];
698   rna_idname_validate(name, safe_name);
699 
700   Volume *volume = BKE_volume_add(bmain, safe_name);
701   id_us_min(&volume->id);
702   return volume;
703 }
704 
705 #  ifdef WITH_GEOMETRY_NODES
rna_Main_simulations_new(Main * bmain,const char * name)706 static Simulation *rna_Main_simulations_new(Main *bmain, const char *name)
707 {
708   char safe_name[MAX_ID_NAME - 2];
709   rna_idname_validate(name, safe_name);
710 
711   Simulation *simulation = BKE_simulation_add(bmain, safe_name);
712   id_us_min(&simulation->id);
713   return simulation;
714 }
715 #  endif
716 
717 /* tag functions, all the same */
718 #  define RNA_MAIN_ID_TAG_FUNCS_DEF(_func_name, _listbase_name, _id_type) \
719     static void rna_Main_##_func_name##_tag(Main *bmain, bool value) \
720     { \
721       BKE_main_id_tag_listbase(&bmain->_listbase_name, LIB_TAG_DOIT, value); \
722     }
723 
724 RNA_MAIN_ID_TAG_FUNCS_DEF(cameras, cameras, ID_CA)
725 RNA_MAIN_ID_TAG_FUNCS_DEF(scenes, scenes, ID_SCE)
726 RNA_MAIN_ID_TAG_FUNCS_DEF(objects, objects, ID_OB)
727 RNA_MAIN_ID_TAG_FUNCS_DEF(materials, materials, ID_MA)
728 RNA_MAIN_ID_TAG_FUNCS_DEF(node_groups, nodetrees, ID_NT)
729 RNA_MAIN_ID_TAG_FUNCS_DEF(meshes, meshes, ID_ME)
730 RNA_MAIN_ID_TAG_FUNCS_DEF(lights, lights, ID_LA)
731 RNA_MAIN_ID_TAG_FUNCS_DEF(libraries, libraries, ID_LI)
732 RNA_MAIN_ID_TAG_FUNCS_DEF(screens, screens, ID_SCR)
733 RNA_MAIN_ID_TAG_FUNCS_DEF(window_managers, wm, ID_WM)
734 RNA_MAIN_ID_TAG_FUNCS_DEF(images, images, ID_IM)
735 RNA_MAIN_ID_TAG_FUNCS_DEF(lattices, lattices, ID_LT)
736 RNA_MAIN_ID_TAG_FUNCS_DEF(curves, curves, ID_CU)
737 RNA_MAIN_ID_TAG_FUNCS_DEF(metaballs, metaballs, ID_MB)
738 RNA_MAIN_ID_TAG_FUNCS_DEF(fonts, fonts, ID_VF)
739 RNA_MAIN_ID_TAG_FUNCS_DEF(textures, textures, ID_TE)
740 RNA_MAIN_ID_TAG_FUNCS_DEF(brushes, brushes, ID_BR)
741 RNA_MAIN_ID_TAG_FUNCS_DEF(worlds, worlds, ID_WO)
742 RNA_MAIN_ID_TAG_FUNCS_DEF(collections, collections, ID_GR)
743 // RNA_MAIN_ID_TAG_FUNCS_DEF(shape_keys, key, ID_KE)
744 RNA_MAIN_ID_TAG_FUNCS_DEF(texts, texts, ID_TXT)
745 RNA_MAIN_ID_TAG_FUNCS_DEF(speakers, speakers, ID_SPK)
746 RNA_MAIN_ID_TAG_FUNCS_DEF(sounds, sounds, ID_SO)
747 RNA_MAIN_ID_TAG_FUNCS_DEF(armatures, armatures, ID_AR)
748 RNA_MAIN_ID_TAG_FUNCS_DEF(actions, actions, ID_AC)
749 RNA_MAIN_ID_TAG_FUNCS_DEF(particles, particles, ID_PA)
750 RNA_MAIN_ID_TAG_FUNCS_DEF(palettes, palettes, ID_PAL)
751 RNA_MAIN_ID_TAG_FUNCS_DEF(gpencils, gpencils, ID_GD)
752 RNA_MAIN_ID_TAG_FUNCS_DEF(movieclips, movieclips, ID_MC)
753 RNA_MAIN_ID_TAG_FUNCS_DEF(masks, masks, ID_MSK)
754 RNA_MAIN_ID_TAG_FUNCS_DEF(linestyle, linestyles, ID_LS)
755 RNA_MAIN_ID_TAG_FUNCS_DEF(cachefiles, cachefiles, ID_CF)
756 RNA_MAIN_ID_TAG_FUNCS_DEF(paintcurves, paintcurves, ID_PC)
757 RNA_MAIN_ID_TAG_FUNCS_DEF(workspaces, workspaces, ID_WS)
758 RNA_MAIN_ID_TAG_FUNCS_DEF(lightprobes, lightprobes, ID_LP)
759 #  ifdef WITH_HAIR_NODES
760 RNA_MAIN_ID_TAG_FUNCS_DEF(hairs, hairs, ID_HA)
761 #  endif
762 #  ifdef WITH_POINT_CLOUD
763 RNA_MAIN_ID_TAG_FUNCS_DEF(pointclouds, pointclouds, ID_PT)
764 #  endif
765 RNA_MAIN_ID_TAG_FUNCS_DEF(volumes, volumes, ID_VO)
766 #  ifdef WITH_GEOMETRY_NODES
767 RNA_MAIN_ID_TAG_FUNCS_DEF(simulations, simulations, ID_SIM)
768 #  endif
769 
770 #  undef RNA_MAIN_ID_TAG_FUNCS_DEF
771 
772 #else
773 
774 void RNA_api_main(StructRNA *UNUSED(srna))
775 {
776 #  if 0
777   FunctionRNA *func;
778   PropertyRNA *parm;
779 
780   /* maybe we want to add functions in 'bpy.data' still?
781    * for now they are all in collections bpy.data.images.new(...) */
782   func = RNA_def_function(srna, "add_image", "rna_Main_add_image");
783   RNA_def_function_ui_description(func, "Add a new image");
784   parm = RNA_def_string_file_path(func, "filepath", NULL, 0, "", "File path to load image from");
785   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
786   parm = RNA_def_pointer(func, "image", "Image", "", "New image");
787   RNA_def_function_return(func, parm);
788 #  endif
789 }
790 
791 void RNA_def_main_cameras(BlenderRNA *brna, PropertyRNA *cprop)
792 {
793   StructRNA *srna;
794   FunctionRNA *func;
795   PropertyRNA *parm;
796 
797   RNA_def_property_srna(cprop, "BlendDataCameras");
798   srna = RNA_def_struct(brna, "BlendDataCameras", NULL);
799   RNA_def_struct_sdna(srna, "Main");
800   RNA_def_struct_ui_text(srna, "Main Cameras", "Collection of cameras");
801 
802   func = RNA_def_function(srna, "new", "rna_Main_cameras_new");
803   RNA_def_function_ui_description(func, "Add a new camera to the main database");
804   parm = RNA_def_string(func, "name", "Camera", 0, "", "New name for the data-block");
805   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
806   /* return type */
807   parm = RNA_def_pointer(func, "camera", "Camera", "", "New camera data-block");
808   RNA_def_function_return(func, parm);
809 
810   func = RNA_def_function(srna, "remove", "rna_Main_ID_remove");
811   RNA_def_function_flag(func, FUNC_USE_REPORTS);
812   RNA_def_function_ui_description(func, "Remove a camera from the current blendfile");
813   parm = RNA_def_pointer(func, "camera", "Camera", "", "Camera to remove");
814   RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
815   RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
816   RNA_def_boolean(func,
817                   "do_unlink",
818                   true,
819                   "",
820                   "Unlink all usages of this camera before deleting it "
821                   "(WARNING: will also delete objects instancing that camera data)");
822   RNA_def_boolean(func,
823                   "do_id_user",
824                   true,
825                   "",
826                   "Decrement user counter of all datablocks used by this camera");
827   RNA_def_boolean(
828       func, "do_ui_user", true, "", "Make sure interface does not reference this camera");
829 
830   func = RNA_def_function(srna, "tag", "rna_Main_cameras_tag");
831   parm = RNA_def_boolean(func, "value", 0, "Value", "");
832   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
833 }
834 
835 void RNA_def_main_scenes(BlenderRNA *brna, PropertyRNA *cprop)
836 {
837   StructRNA *srna;
838   FunctionRNA *func;
839   PropertyRNA *parm;
840 
841   RNA_def_property_srna(cprop, "BlendDataScenes");
842   srna = RNA_def_struct(brna, "BlendDataScenes", NULL);
843   RNA_def_struct_sdna(srna, "Main");
844   RNA_def_struct_ui_text(srna, "Main Scenes", "Collection of scenes");
845 
846   func = RNA_def_function(srna, "new", "rna_Main_scenes_new");
847   RNA_def_function_ui_description(func, "Add a new scene to the main database");
848   parm = RNA_def_string(func, "name", "Scene", 0, "", "New name for the data-block");
849   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
850   /* return type */
851   parm = RNA_def_pointer(func, "scene", "Scene", "", "New scene data-block");
852   RNA_def_function_return(func, parm);
853 
854   func = RNA_def_function(srna, "remove", "rna_Main_scenes_remove");
855   RNA_def_function_flag(func, FUNC_USE_CONTEXT | FUNC_USE_REPORTS);
856   RNA_def_function_ui_description(func, "Remove a scene from the current blendfile");
857   parm = RNA_def_pointer(func, "scene", "Scene", "", "Scene to remove");
858   RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
859   RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
860   RNA_def_boolean(
861       func, "do_unlink", true, "", "Unlink all usages of this scene before deleting it");
862 
863   func = RNA_def_function(srna, "tag", "rna_Main_scenes_tag");
864   parm = RNA_def_boolean(func, "value", 0, "Value", "");
865   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
866 }
867 
868 void RNA_def_main_objects(BlenderRNA *brna, PropertyRNA *cprop)
869 {
870   StructRNA *srna;
871   FunctionRNA *func;
872   PropertyRNA *parm;
873 
874   RNA_def_property_srna(cprop, "BlendDataObjects");
875   srna = RNA_def_struct(brna, "BlendDataObjects", NULL);
876   RNA_def_struct_sdna(srna, "Main");
877   RNA_def_struct_ui_text(srna, "Main Objects", "Collection of objects");
878 
879   func = RNA_def_function(srna, "new", "rna_Main_objects_new");
880   RNA_def_function_flag(func, FUNC_USE_REPORTS);
881   RNA_def_function_ui_description(func, "Add a new object to the main database");
882   parm = RNA_def_string(func, "name", "Object", 0, "", "New name for the data-block");
883   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
884   parm = RNA_def_pointer(func, "object_data", "ID", "", "Object data or None for an empty object");
885   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
886 
887   /* return type */
888   parm = RNA_def_pointer(func, "object", "Object", "", "New object data-block");
889   RNA_def_function_return(func, parm);
890 
891   func = RNA_def_function(srna, "remove", "rna_Main_ID_remove");
892   RNA_def_function_ui_description(func, "Remove a object from the current blendfile");
893   RNA_def_function_flag(func, FUNC_USE_REPORTS);
894   parm = RNA_def_pointer(func, "object", "Object", "", "Object to remove");
895   RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
896   RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
897   RNA_def_boolean(
898       func, "do_unlink", true, "", "Unlink all usages of this object before deleting it");
899   RNA_def_boolean(func,
900                   "do_id_user",
901                   true,
902                   "",
903                   "Decrement user counter of all datablocks used by this object");
904   RNA_def_boolean(
905       func, "do_ui_user", true, "", "Make sure interface does not reference this object");
906 
907   func = RNA_def_function(srna, "tag", "rna_Main_objects_tag");
908   parm = RNA_def_boolean(func, "value", 0, "Value", "");
909   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
910 }
911 
912 void RNA_def_main_materials(BlenderRNA *brna, PropertyRNA *cprop)
913 {
914   StructRNA *srna;
915   FunctionRNA *func;
916   PropertyRNA *parm;
917 
918   RNA_def_property_srna(cprop, "BlendDataMaterials");
919   srna = RNA_def_struct(brna, "BlendDataMaterials", NULL);
920   RNA_def_struct_sdna(srna, "Main");
921   RNA_def_struct_ui_text(srna, "Main Materials", "Collection of materials");
922 
923   func = RNA_def_function(srna, "new", "rna_Main_materials_new");
924   RNA_def_function_ui_description(func, "Add a new material to the main database");
925   parm = RNA_def_string(func, "name", "Material", 0, "", "New name for the data-block");
926   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
927   /* return type */
928   parm = RNA_def_pointer(func, "material", "Material", "", "New material data-block");
929   RNA_def_function_return(func, parm);
930 
931   func = RNA_def_function(srna, "create_gpencil_data", "rna_Main_materials_gpencil_data");
932   RNA_def_function_ui_description(func, "Add grease pencil material settings");
933   parm = RNA_def_pointer(func, "material", "Material", "", "Material");
934   RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
935 
936   func = RNA_def_function(srna, "remove_gpencil_data", "rna_Main_materials_gpencil_remove");
937   RNA_def_function_ui_description(func, "Remove grease pencil material settings");
938   parm = RNA_def_pointer(func, "material", "Material", "", "Material");
939   RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
940 
941   func = RNA_def_function(srna, "remove", "rna_Main_ID_remove");
942   RNA_def_function_flag(func, FUNC_USE_REPORTS);
943   RNA_def_function_ui_description(func, "Remove a material from the current blendfile");
944   parm = RNA_def_pointer(func, "material", "Material", "", "Material to remove");
945   RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
946   RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
947   RNA_def_boolean(
948       func, "do_unlink", true, "", "Unlink all usages of this material before deleting it");
949   RNA_def_boolean(func,
950                   "do_id_user",
951                   true,
952                   "",
953                   "Decrement user counter of all datablocks used by this material");
954   RNA_def_boolean(
955       func, "do_ui_user", true, "", "Make sure interface does not reference this material");
956 
957   func = RNA_def_function(srna, "tag", "rna_Main_materials_tag");
958   parm = RNA_def_boolean(func, "value", 0, "Value", "");
959   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
960 }
961 void RNA_def_main_node_groups(BlenderRNA *brna, PropertyRNA *cprop)
962 {
963   StructRNA *srna;
964   FunctionRNA *func;
965   PropertyRNA *parm;
966 
967   static const EnumPropertyItem dummy_items[] = {
968       {0, "DUMMY", 0, "", ""},
969       {0, NULL, 0, NULL, NULL},
970   };
971 
972   RNA_def_property_srna(cprop, "BlendDataNodeTrees");
973   srna = RNA_def_struct(brna, "BlendDataNodeTrees", NULL);
974   RNA_def_struct_sdna(srna, "Main");
975   RNA_def_struct_ui_text(srna, "Main Node Trees", "Collection of node trees");
976 
977   func = RNA_def_function(srna, "new", "rna_Main_nodetree_new");
978   RNA_def_function_ui_description(func, "Add a new node tree to the main database");
979   parm = RNA_def_string(func, "name", "NodeGroup", 0, "", "New name for the data-block");
980   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
981   parm = RNA_def_enum(func, "type", dummy_items, 0, "Type", "The type of node_group to add");
982   RNA_def_property_enum_funcs(parm, NULL, NULL, "rna_Main_nodetree_type_itemf");
983   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
984   /* return type */
985   parm = RNA_def_pointer(func, "tree", "NodeTree", "", "New node tree data-block");
986   RNA_def_function_return(func, parm);
987 
988   func = RNA_def_function(srna, "remove", "rna_Main_ID_remove");
989   RNA_def_function_flag(func, FUNC_USE_REPORTS);
990   RNA_def_function_ui_description(func, "Remove a node tree from the current blendfile");
991   parm = RNA_def_pointer(func, "tree", "NodeTree", "", "Node tree to remove");
992   RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
993   RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
994   RNA_def_boolean(
995       func, "do_unlink", true, "", "Unlink all usages of this node tree before deleting it");
996   RNA_def_boolean(func,
997                   "do_id_user",
998                   true,
999                   "",
1000                   "Decrement user counter of all datablocks used by this node tree");
1001   RNA_def_boolean(
1002       func, "do_ui_user", true, "", "Make sure interface does not reference this node tree");
1003 
1004   func = RNA_def_function(srna, "tag", "rna_Main_node_groups_tag");
1005   parm = RNA_def_boolean(func, "value", 0, "Value", "");
1006   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1007 }
1008 void RNA_def_main_meshes(BlenderRNA *brna, PropertyRNA *cprop)
1009 {
1010   StructRNA *srna;
1011   FunctionRNA *func;
1012   PropertyRNA *parm;
1013 
1014   RNA_def_property_srna(cprop, "BlendDataMeshes");
1015   srna = RNA_def_struct(brna, "BlendDataMeshes", NULL);
1016   RNA_def_struct_sdna(srna, "Main");
1017   RNA_def_struct_ui_text(srna, "Main Meshes", "Collection of meshes");
1018 
1019   func = RNA_def_function(srna, "new", "rna_Main_meshes_new");
1020   RNA_def_function_ui_description(func, "Add a new mesh to the main database");
1021   parm = RNA_def_string(func, "name", "Mesh", 0, "", "New name for the data-block");
1022   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1023   /* return type */
1024   parm = RNA_def_pointer(func, "mesh", "Mesh", "", "New mesh data-block");
1025   RNA_def_function_return(func, parm);
1026 
1027   func = RNA_def_function(srna, "new_from_object", "rna_Main_meshes_new_from_object");
1028   RNA_def_function_ui_description(
1029       func,
1030       "Add a new mesh created from given object (undeformed geometry if object is original, and "
1031       "final evaluated geometry, with all modifiers etc., if object is evaluated)");
1032   RNA_def_function_flag(func, FUNC_USE_REPORTS);
1033   parm = RNA_def_pointer(func, "object", "Object", "", "Object to create mesh from");
1034   RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
1035   RNA_def_boolean(func,
1036                   "preserve_all_data_layers",
1037                   false,
1038                   "",
1039                   "Preserve all data layers in the mesh, like UV maps and vertex groups. "
1040                   "By default Blender only computes the subset of data layers needed for viewport "
1041                   "display and rendering, for better performance");
1042   RNA_def_pointer(
1043       func,
1044       "depsgraph",
1045       "Depsgraph",
1046       "Dependency Graph",
1047       "Evaluated dependency graph which is required when preserve_all_data_layers is true");
1048   parm = RNA_def_pointer(func,
1049                          "mesh",
1050                          "Mesh",
1051                          "",
1052                          "Mesh created from object, remove it if it is only used for export");
1053   RNA_def_function_return(func, parm);
1054 
1055   func = RNA_def_function(srna, "remove", "rna_Main_ID_remove");
1056   RNA_def_function_flag(func, FUNC_USE_REPORTS);
1057   RNA_def_function_ui_description(func, "Remove a mesh from the current blendfile");
1058   parm = RNA_def_pointer(func, "mesh", "Mesh", "", "Mesh to remove");
1059   RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
1060   RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
1061   RNA_def_boolean(func,
1062                   "do_unlink",
1063                   true,
1064                   "",
1065                   "Unlink all usages of this mesh before deleting it "
1066                   "(WARNING: will also delete objects instancing that mesh data)");
1067   RNA_def_boolean(func,
1068                   "do_id_user",
1069                   true,
1070                   "",
1071                   "Decrement user counter of all datablocks used by this mesh data");
1072   RNA_def_boolean(
1073       func, "do_ui_user", true, "", "Make sure interface does not reference this mesh data");
1074 
1075   func = RNA_def_function(srna, "tag", "rna_Main_meshes_tag");
1076   parm = RNA_def_boolean(func, "value", 0, "Value", "");
1077   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1078 }
1079 
1080 void RNA_def_main_lights(BlenderRNA *brna, PropertyRNA *cprop)
1081 {
1082   StructRNA *srna;
1083   FunctionRNA *func;
1084   PropertyRNA *parm;
1085 
1086   RNA_def_property_srna(cprop, "BlendDataLights");
1087   srna = RNA_def_struct(brna, "BlendDataLights", NULL);
1088   RNA_def_struct_sdna(srna, "Main");
1089   RNA_def_struct_ui_text(srna, "Main Lights", "Collection of lights");
1090 
1091   func = RNA_def_function(srna, "new", "rna_Main_lights_new");
1092   RNA_def_function_ui_description(func, "Add a new light to the main database");
1093   parm = RNA_def_string(func, "name", "Light", 0, "", "New name for the data-block");
1094   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1095   parm = RNA_def_enum(
1096       func, "type", rna_enum_light_type_items, 0, "Type", "The type of texture to add");
1097   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1098   /* return type */
1099   parm = RNA_def_pointer(func, "light", "Light", "", "New light data-block");
1100   RNA_def_function_return(func, parm);
1101 
1102   func = RNA_def_function(srna, "remove", "rna_Main_ID_remove");
1103   RNA_def_function_flag(func, FUNC_USE_REPORTS);
1104   RNA_def_function_ui_description(func, "Remove a light from the current blendfile");
1105   parm = RNA_def_pointer(func, "light", "Light", "", "Light to remove");
1106   RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
1107   RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
1108   RNA_def_boolean(func,
1109                   "do_unlink",
1110                   true,
1111                   "",
1112                   "Unlink all usages of this Light before deleting it "
1113                   "(WARNING: will also delete objects instancing that light data)");
1114   RNA_def_boolean(func,
1115                   "do_id_user",
1116                   true,
1117                   "",
1118                   "Decrement user counter of all datablocks used by this light data");
1119   RNA_def_boolean(
1120       func, "do_ui_user", true, "", "Make sure interface does not reference this light data");
1121 
1122   func = RNA_def_function(srna, "tag", "rna_Main_lights_tag");
1123   parm = RNA_def_boolean(func, "value", 0, "Value", "");
1124   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1125 }
1126 
1127 void RNA_def_main_libraries(BlenderRNA *brna, PropertyRNA *cprop)
1128 {
1129   StructRNA *srna;
1130   FunctionRNA *func;
1131   PropertyRNA *parm;
1132 
1133   RNA_def_property_srna(cprop, "BlendDataLibraries");
1134   srna = RNA_def_struct(brna, "BlendDataLibraries", NULL);
1135   RNA_def_struct_sdna(srna, "Main");
1136   RNA_def_struct_ui_text(srna, "Main Libraries", "Collection of libraries");
1137 
1138   func = RNA_def_function(srna, "tag", "rna_Main_libraries_tag");
1139   parm = RNA_def_boolean(func, "value", 0, "Value", "");
1140   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1141 
1142   func = RNA_def_function(srna, "remove", "rna_Main_ID_remove");
1143   RNA_def_function_flag(func, FUNC_USE_REPORTS);
1144   RNA_def_function_ui_description(func, "Remove a camera from the current blendfile");
1145   parm = RNA_def_pointer(func, "library", "Library", "", "Library to remove");
1146   RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
1147   RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
1148   RNA_def_boolean(
1149       func, "do_unlink", true, "", "Unlink all usages of this library before deleting it");
1150   RNA_def_boolean(func,
1151                   "do_id_user",
1152                   true,
1153                   "",
1154                   "Decrement user counter of all datablocks used by this object");
1155   RNA_def_boolean(
1156       func, "do_ui_user", true, "", "Make sure interface does not reference this object");
1157 }
1158 
1159 void RNA_def_main_screens(BlenderRNA *brna, PropertyRNA *cprop)
1160 {
1161   StructRNA *srna;
1162   FunctionRNA *func;
1163   PropertyRNA *parm;
1164 
1165   RNA_def_property_srna(cprop, "BlendDataScreens");
1166   srna = RNA_def_struct(brna, "BlendDataScreens", NULL);
1167   RNA_def_struct_sdna(srna, "Main");
1168   RNA_def_struct_ui_text(srna, "Main Screens", "Collection of screens");
1169 
1170   func = RNA_def_function(srna, "tag", "rna_Main_screens_tag");
1171   parm = RNA_def_boolean(func, "value", 0, "Value", "");
1172   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1173 }
1174 
1175 void RNA_def_main_window_managers(BlenderRNA *brna, PropertyRNA *cprop)
1176 {
1177   StructRNA *srna;
1178   FunctionRNA *func;
1179   PropertyRNA *parm;
1180 
1181   RNA_def_property_srna(cprop, "BlendDataWindowManagers");
1182   srna = RNA_def_struct(brna, "BlendDataWindowManagers", NULL);
1183   RNA_def_struct_sdna(srna, "Main");
1184   RNA_def_struct_ui_text(srna, "Main Window Managers", "Collection of window managers");
1185 
1186   func = RNA_def_function(srna, "tag", "rna_Main_window_managers_tag");
1187   parm = RNA_def_boolean(func, "value", 0, "Value", "");
1188   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1189 }
1190 void RNA_def_main_images(BlenderRNA *brna, PropertyRNA *cprop)
1191 {
1192   StructRNA *srna;
1193   FunctionRNA *func;
1194   PropertyRNA *parm;
1195 
1196   RNA_def_property_srna(cprop, "BlendDataImages");
1197   srna = RNA_def_struct(brna, "BlendDataImages", NULL);
1198   RNA_def_struct_sdna(srna, "Main");
1199   RNA_def_struct_ui_text(srna, "Main Images", "Collection of images");
1200 
1201   func = RNA_def_function(srna, "new", "rna_Main_images_new");
1202   RNA_def_function_ui_description(func, "Add a new image to the main database");
1203   parm = RNA_def_string(func, "name", "Image", 0, "", "New name for the data-block");
1204   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1205   parm = RNA_def_int(func, "width", 1024, 1, INT_MAX, "", "Width of the image", 1, INT_MAX);
1206   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1207   parm = RNA_def_int(func, "height", 1024, 1, INT_MAX, "", "Height of the image", 1, INT_MAX);
1208   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1209   RNA_def_boolean(func, "alpha", 0, "Alpha", "Use alpha channel");
1210   RNA_def_boolean(
1211       func, "float_buffer", 0, "Float Buffer", "Create an image with floating point color");
1212   RNA_def_boolean(func, "stereo3d", 0, "Stereo 3D", "Create left and right views");
1213   RNA_def_boolean(func, "is_data", 0, "Is Data", "Create image with non-color data color space");
1214   RNA_def_boolean(func, "tiled", 0, "Tiled", "Create a tiled image");
1215   /* return type */
1216   parm = RNA_def_pointer(func, "image", "Image", "", "New image data-block");
1217   RNA_def_function_return(func, parm);
1218 
1219   func = RNA_def_function(srna, "load", "rna_Main_images_load");
1220   RNA_def_function_flag(func, FUNC_USE_REPORTS);
1221   RNA_def_function_ui_description(func, "Load a new image into the main database");
1222   parm = RNA_def_string_file_path(
1223       func, "filepath", "File Path", 0, "", "path of the file to load");
1224   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1225   RNA_def_boolean(func,
1226                   "check_existing",
1227                   false,
1228                   "",
1229                   "Using existing data-block if this file is already loaded");
1230   /* return type */
1231   parm = RNA_def_pointer(func, "image", "Image", "", "New image data-block");
1232   RNA_def_function_return(func, parm);
1233 
1234   func = RNA_def_function(srna, "remove", "rna_Main_ID_remove");
1235   RNA_def_function_flag(func, FUNC_USE_REPORTS);
1236   RNA_def_function_ui_description(func, "Remove an image from the current blendfile");
1237   parm = RNA_def_pointer(func, "image", "Image", "", "Image to remove");
1238   RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
1239   RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
1240   RNA_def_boolean(
1241       func, "do_unlink", true, "", "Unlink all usages of this image before deleting it");
1242   RNA_def_boolean(
1243       func, "do_id_user", true, "", "Decrement user counter of all datablocks used by this image");
1244   RNA_def_boolean(
1245       func, "do_ui_user", true, "", "Make sure interface does not reference this image");
1246 
1247   func = RNA_def_function(srna, "tag", "rna_Main_images_tag");
1248   parm = RNA_def_boolean(func, "value", 0, "Value", "");
1249   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1250 }
1251 
1252 void RNA_def_main_lattices(BlenderRNA *brna, PropertyRNA *cprop)
1253 {
1254   StructRNA *srna;
1255   FunctionRNA *func;
1256   PropertyRNA *parm;
1257 
1258   RNA_def_property_srna(cprop, "BlendDataLattices");
1259   srna = RNA_def_struct(brna, "BlendDataLattices", NULL);
1260   RNA_def_struct_sdna(srna, "Main");
1261   RNA_def_struct_ui_text(srna, "Main Lattices", "Collection of lattices");
1262 
1263   func = RNA_def_function(srna, "new", "rna_Main_lattices_new");
1264   RNA_def_function_ui_description(func, "Add a new lattice to the main database");
1265   parm = RNA_def_string(func, "name", "Lattice", 0, "", "New name for the data-block");
1266   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1267   /* return type */
1268   parm = RNA_def_pointer(func, "lattice", "Lattice", "", "New lattices data-block");
1269   RNA_def_function_return(func, parm);
1270 
1271   func = RNA_def_function(srna, "remove", "rna_Main_ID_remove");
1272   RNA_def_function_flag(func, FUNC_USE_REPORTS);
1273   RNA_def_function_ui_description(func, "Remove a lattice from the current blendfile");
1274   parm = RNA_def_pointer(func, "lattice", "Lattice", "", "Lattice to remove");
1275   RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
1276   RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
1277   RNA_def_boolean(func,
1278                   "do_unlink",
1279                   true,
1280                   "",
1281                   "Unlink all usages of this lattice before deleting it "
1282                   "(WARNING: will also delete objects instancing that lattice data)");
1283   RNA_def_boolean(func,
1284                   "do_id_user",
1285                   true,
1286                   "",
1287                   "Decrement user counter of all datablocks used by this lattice data");
1288   RNA_def_boolean(
1289       func, "do_ui_user", true, "", "Make sure interface does not reference this lattice data");
1290 
1291   func = RNA_def_function(srna, "tag", "rna_Main_lattices_tag");
1292   parm = RNA_def_boolean(func, "value", 0, "Value", "");
1293   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1294 }
1295 void RNA_def_main_curves(BlenderRNA *brna, PropertyRNA *cprop)
1296 {
1297   StructRNA *srna;
1298   FunctionRNA *func;
1299   PropertyRNA *parm;
1300 
1301   RNA_def_property_srna(cprop, "BlendDataCurves");
1302   srna = RNA_def_struct(brna, "BlendDataCurves", NULL);
1303   RNA_def_struct_sdna(srna, "Main");
1304   RNA_def_struct_ui_text(srna, "Main Curves", "Collection of curves");
1305 
1306   func = RNA_def_function(srna, "new", "rna_Main_curves_new");
1307   RNA_def_function_ui_description(func, "Add a new curve to the main database");
1308   parm = RNA_def_string(func, "name", "Curve", 0, "", "New name for the data-block");
1309   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1310   parm = RNA_def_enum(
1311       func, "type", rna_enum_object_type_curve_items, 0, "Type", "The type of curve to add");
1312   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1313   /* return type */
1314   parm = RNA_def_pointer(func, "curve", "Curve", "", "New curve data-block");
1315   RNA_def_function_return(func, parm);
1316 
1317   func = RNA_def_function(srna, "remove", "rna_Main_ID_remove");
1318   RNA_def_function_flag(func, FUNC_USE_REPORTS);
1319   RNA_def_function_ui_description(func, "Remove a curve from the current blendfile");
1320   parm = RNA_def_pointer(func, "curve", "Curve", "", "Curve to remove");
1321   RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
1322   RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
1323   RNA_def_boolean(func,
1324                   "do_unlink",
1325                   true,
1326                   "",
1327                   "Unlink all usages of this curve before deleting it "
1328                   "(WARNING: will also delete objects instancing that curve data)");
1329   RNA_def_boolean(func,
1330                   "do_id_user",
1331                   true,
1332                   "",
1333                   "Decrement user counter of all datablocks used by this curve data");
1334   RNA_def_boolean(
1335       func, "do_ui_user", true, "", "Make sure interface does not reference this curve data");
1336 
1337   func = RNA_def_function(srna, "tag", "rna_Main_curves_tag");
1338   parm = RNA_def_boolean(func, "value", 0, "Value", "");
1339   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1340 }
1341 void RNA_def_main_metaballs(BlenderRNA *brna, PropertyRNA *cprop)
1342 {
1343   StructRNA *srna;
1344   FunctionRNA *func;
1345   PropertyRNA *parm;
1346 
1347   RNA_def_property_srna(cprop, "BlendDataMetaBalls");
1348   srna = RNA_def_struct(brna, "BlendDataMetaBalls", NULL);
1349   RNA_def_struct_sdna(srna, "Main");
1350   RNA_def_struct_ui_text(srna, "Main Metaballs", "Collection of metaballs");
1351 
1352   func = RNA_def_function(srna, "new", "rna_Main_metaballs_new");
1353   RNA_def_function_ui_description(func, "Add a new metaball to the main database");
1354   parm = RNA_def_string(func, "name", "MetaBall", 0, "", "New name for the data-block");
1355   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1356   /* return type */
1357   parm = RNA_def_pointer(func, "metaball", "MetaBall", "", "New metaball data-block");
1358   RNA_def_function_return(func, parm);
1359 
1360   func = RNA_def_function(srna, "remove", "rna_Main_ID_remove");
1361   RNA_def_function_flag(func, FUNC_USE_REPORTS);
1362   RNA_def_function_ui_description(func, "Remove a metaball from the current blendfile");
1363   parm = RNA_def_pointer(func, "metaball", "MetaBall", "", "Metaball to remove");
1364   RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
1365   RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
1366   RNA_def_boolean(func,
1367                   "do_unlink",
1368                   true,
1369                   "",
1370                   "Unlink all usages of this metaball before deleting it "
1371                   "(WARNING: will also delete objects instancing that metaball data)");
1372   RNA_def_boolean(func,
1373                   "do_id_user",
1374                   true,
1375                   "",
1376                   "Decrement user counter of all datablocks used by this metaball data");
1377   RNA_def_boolean(
1378       func, "do_ui_user", true, "", "Make sure interface does not reference this metaball data");
1379 
1380   func = RNA_def_function(srna, "tag", "rna_Main_metaballs_tag");
1381   parm = RNA_def_boolean(func, "value", 0, "Value", "");
1382   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1383 }
1384 void RNA_def_main_fonts(BlenderRNA *brna, PropertyRNA *cprop)
1385 {
1386   StructRNA *srna;
1387   FunctionRNA *func;
1388   PropertyRNA *parm;
1389 
1390   RNA_def_property_srna(cprop, "BlendDataFonts");
1391   srna = RNA_def_struct(brna, "BlendDataFonts", NULL);
1392   RNA_def_struct_sdna(srna, "Main");
1393   RNA_def_struct_ui_text(srna, "Main Fonts", "Collection of fonts");
1394 
1395   func = RNA_def_function(srna, "load", "rna_Main_fonts_load");
1396   RNA_def_function_flag(func, FUNC_USE_REPORTS);
1397   RNA_def_function_ui_description(func, "Load a new font into the main database");
1398   parm = RNA_def_string_file_path(
1399       func, "filepath", "File Path", 0, "", "path of the font to load");
1400   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1401   RNA_def_boolean(func,
1402                   "check_existing",
1403                   false,
1404                   "",
1405                   "Using existing data-block if this file is already loaded");
1406   /* return type */
1407   parm = RNA_def_pointer(func, "vfont", "VectorFont", "", "New font data-block");
1408   RNA_def_function_return(func, parm);
1409 
1410   func = RNA_def_function(srna, "remove", "rna_Main_ID_remove");
1411   RNA_def_function_flag(func, FUNC_USE_REPORTS);
1412   RNA_def_function_ui_description(func, "Remove a font from the current blendfile");
1413   parm = RNA_def_pointer(func, "vfont", "VectorFont", "", "Font to remove");
1414   RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
1415   RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
1416   RNA_def_boolean(
1417       func, "do_unlink", true, "", "Unlink all usages of this font before deleting it");
1418   RNA_def_boolean(
1419       func, "do_id_user", true, "", "Decrement user counter of all datablocks used by this font");
1420   RNA_def_boolean(
1421       func, "do_ui_user", true, "", "Make sure interface does not reference this font");
1422 
1423   func = RNA_def_function(srna, "tag", "rna_Main_fonts_tag");
1424   parm = RNA_def_boolean(func, "value", 0, "Value", "");
1425   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1426 }
1427 void RNA_def_main_textures(BlenderRNA *brna, PropertyRNA *cprop)
1428 {
1429   StructRNA *srna;
1430   FunctionRNA *func;
1431   PropertyRNA *parm;
1432 
1433   RNA_def_property_srna(cprop, "BlendDataTextures");
1434   srna = RNA_def_struct(brna, "BlendDataTextures", NULL);
1435   RNA_def_struct_sdna(srna, "Main");
1436   RNA_def_struct_ui_text(srna, "Main Textures", "Collection of textures");
1437 
1438   func = RNA_def_function(srna, "new", "rna_Main_textures_new");
1439   RNA_def_function_ui_description(func, "Add a new texture to the main database");
1440   parm = RNA_def_string(func, "name", "Texture", 0, "", "New name for the data-block");
1441   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1442   parm = RNA_def_enum(
1443       func, "type", rna_enum_texture_type_items, 0, "Type", "The type of texture to add");
1444   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1445   /* return type */
1446   parm = RNA_def_pointer(func, "texture", "Texture", "", "New texture data-block");
1447   RNA_def_function_return(func, parm);
1448 
1449   func = RNA_def_function(srna, "remove", "rna_Main_ID_remove");
1450   RNA_def_function_flag(func, FUNC_USE_REPORTS);
1451   RNA_def_function_ui_description(func, "Remove a texture from the current blendfile");
1452   parm = RNA_def_pointer(func, "texture", "Texture", "", "Texture to remove");
1453   RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
1454   RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
1455   RNA_def_boolean(
1456       func, "do_unlink", true, "", "Unlink all usages of this texture before deleting it");
1457   RNA_def_boolean(func,
1458                   "do_id_user",
1459                   true,
1460                   "",
1461                   "Decrement user counter of all datablocks used by this texture");
1462   RNA_def_boolean(
1463       func, "do_ui_user", true, "", "Make sure interface does not reference this texture");
1464 
1465   func = RNA_def_function(srna, "tag", "rna_Main_textures_tag");
1466   parm = RNA_def_boolean(func, "value", 0, "Value", "");
1467   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1468 }
1469 void RNA_def_main_brushes(BlenderRNA *brna, PropertyRNA *cprop)
1470 {
1471   StructRNA *srna;
1472   FunctionRNA *func;
1473   PropertyRNA *parm;
1474 
1475   RNA_def_property_srna(cprop, "BlendDataBrushes");
1476   srna = RNA_def_struct(brna, "BlendDataBrushes", NULL);
1477   RNA_def_struct_sdna(srna, "Main");
1478   RNA_def_struct_ui_text(srna, "Main Brushes", "Collection of brushes");
1479 
1480   func = RNA_def_function(srna, "new", "rna_Main_brushes_new");
1481   RNA_def_function_ui_description(func, "Add a new brush to the main database");
1482   parm = RNA_def_string(func, "name", "Brush", 0, "", "New name for the data-block");
1483   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1484   parm = RNA_def_enum(func,
1485                       "mode",
1486                       rna_enum_object_mode_items,
1487                       OB_MODE_TEXTURE_PAINT,
1488                       "",
1489                       "Paint Mode for the new brush");
1490   /* return type */
1491   parm = RNA_def_pointer(func, "brush", "Brush", "", "New brush data-block");
1492   RNA_def_function_return(func, parm);
1493 
1494   func = RNA_def_function(srna, "remove", "rna_Main_ID_remove");
1495   RNA_def_function_flag(func, FUNC_USE_REPORTS);
1496   RNA_def_function_ui_description(func, "Remove a brush from the current blendfile");
1497   parm = RNA_def_pointer(func, "brush", "Brush", "", "Brush to remove");
1498   RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
1499   RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
1500   RNA_def_boolean(
1501       func, "do_unlink", true, "", "Unlink all usages of this brush before deleting it");
1502   RNA_def_boolean(
1503       func, "do_id_user", true, "", "Decrement user counter of all datablocks used by this brush");
1504   RNA_def_boolean(
1505       func, "do_ui_user", true, "", "Make sure interface does not reference this brush");
1506 
1507   func = RNA_def_function(srna, "tag", "rna_Main_brushes_tag");
1508   parm = RNA_def_boolean(func, "value", 0, "Value", "");
1509   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1510 
1511   func = RNA_def_function(srna, "create_gpencil_data", "rna_Main_brush_gpencil_data");
1512   RNA_def_function_ui_description(func, "Add grease pencil brush settings");
1513   parm = RNA_def_pointer(func, "brush", "Brush", "", "Brush");
1514   RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
1515 }
1516 
1517 void RNA_def_main_worlds(BlenderRNA *brna, PropertyRNA *cprop)
1518 {
1519   StructRNA *srna;
1520   FunctionRNA *func;
1521   PropertyRNA *parm;
1522 
1523   RNA_def_property_srna(cprop, "BlendDataWorlds");
1524   srna = RNA_def_struct(brna, "BlendDataWorlds", NULL);
1525   RNA_def_struct_sdna(srna, "Main");
1526   RNA_def_struct_ui_text(srna, "Main Worlds", "Collection of worlds");
1527 
1528   func = RNA_def_function(srna, "new", "rna_Main_worlds_new");
1529   RNA_def_function_ui_description(func, "Add a new world to the main database");
1530   parm = RNA_def_string(func, "name", "World", 0, "", "New name for the data-block");
1531   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1532   /* return type */
1533   parm = RNA_def_pointer(func, "world", "World", "", "New world data-block");
1534   RNA_def_function_return(func, parm);
1535 
1536   func = RNA_def_function(srna, "remove", "rna_Main_ID_remove");
1537   RNA_def_function_flag(func, FUNC_USE_REPORTS);
1538   RNA_def_function_ui_description(func, "Remove a world from the current blendfile");
1539   parm = RNA_def_pointer(func, "world", "World", "", "World to remove");
1540   RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
1541   RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
1542   RNA_def_boolean(
1543       func, "do_unlink", true, "", "Unlink all usages of this world before deleting it");
1544   RNA_def_boolean(
1545       func, "do_id_user", true, "", "Decrement user counter of all datablocks used by this world");
1546   RNA_def_boolean(
1547       func, "do_ui_user", true, "", "Make sure interface does not reference this world");
1548 
1549   func = RNA_def_function(srna, "tag", "rna_Main_worlds_tag");
1550   parm = RNA_def_boolean(func, "value", 0, "Value", "");
1551   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1552 }
1553 
1554 void RNA_def_main_collections(BlenderRNA *brna, PropertyRNA *cprop)
1555 {
1556   StructRNA *srna;
1557   FunctionRNA *func;
1558   PropertyRNA *parm;
1559 
1560   RNA_def_property_srna(cprop, "BlendDataCollections");
1561   srna = RNA_def_struct(brna, "BlendDataCollections", NULL);
1562   RNA_def_struct_sdna(srna, "Main");
1563   RNA_def_struct_ui_text(srna, "Main Collections", "Collection of collections");
1564 
1565   func = RNA_def_function(srna, "new", "rna_Main_collections_new");
1566   RNA_def_function_ui_description(func, "Add a new collection to the main database");
1567   parm = RNA_def_string(func, "name", "Collection", 0, "", "New name for the data-block");
1568   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1569   /* return type */
1570   parm = RNA_def_pointer(func, "collection", "Collection", "", "New collection data-block");
1571   RNA_def_function_return(func, parm);
1572 
1573   func = RNA_def_function(srna, "remove", "rna_Main_ID_remove");
1574   RNA_def_function_ui_description(func, "Remove a collection from the current blendfile");
1575   RNA_def_function_flag(func, FUNC_USE_REPORTS);
1576   parm = RNA_def_pointer(func, "collection", "Collection", "", "Collection to remove");
1577   RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
1578   RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
1579   RNA_def_boolean(
1580       func, "do_unlink", true, "", "Unlink all usages of this collection before deleting it");
1581   RNA_def_boolean(func,
1582                   "do_id_user",
1583                   true,
1584                   "",
1585                   "Decrement user counter of all datablocks used by this collection");
1586   RNA_def_boolean(
1587       func, "do_ui_user", true, "", "Make sure interface does not reference this collection");
1588 
1589   func = RNA_def_function(srna, "tag", "rna_Main_collections_tag");
1590   parm = RNA_def_boolean(func, "value", 0, "Value", "");
1591   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1592 }
1593 
1594 void RNA_def_main_speakers(BlenderRNA *brna, PropertyRNA *cprop)
1595 {
1596   StructRNA *srna;
1597   FunctionRNA *func;
1598   PropertyRNA *parm;
1599 
1600   RNA_def_property_srna(cprop, "BlendDataSpeakers");
1601   srna = RNA_def_struct(brna, "BlendDataSpeakers", NULL);
1602   RNA_def_struct_sdna(srna, "Main");
1603   RNA_def_struct_ui_text(srna, "Main Speakers", "Collection of speakers");
1604 
1605   func = RNA_def_function(srna, "new", "rna_Main_speakers_new");
1606   RNA_def_function_ui_description(func, "Add a new speaker to the main database");
1607   parm = RNA_def_string(func, "name", "Speaker", 0, "", "New name for the data-block");
1608   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1609   /* return type */
1610   parm = RNA_def_pointer(func, "speaker", "Speaker", "", "New speaker data-block");
1611   RNA_def_function_return(func, parm);
1612 
1613   func = RNA_def_function(srna, "remove", "rna_Main_ID_remove");
1614   RNA_def_function_flag(func, FUNC_USE_REPORTS);
1615   RNA_def_function_ui_description(func, "Remove a speaker from the current blendfile");
1616   parm = RNA_def_pointer(func, "speaker", "Speaker", "", "Speaker to remove");
1617   RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
1618   RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
1619   RNA_def_boolean(func,
1620                   "do_unlink",
1621                   true,
1622                   "",
1623                   "Unlink all usages of this speaker before deleting it "
1624                   "(WARNING: will also delete objects instancing that speaker data)");
1625   RNA_def_boolean(func,
1626                   "do_id_user",
1627                   true,
1628                   "",
1629                   "Decrement user counter of all datablocks used by this speaker data");
1630   RNA_def_boolean(
1631       func, "do_ui_user", true, "", "Make sure interface does not reference this speaker data");
1632 
1633   func = RNA_def_function(srna, "tag", "rna_Main_speakers_tag");
1634   parm = RNA_def_boolean(func, "value", 0, "Value", "");
1635   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1636 }
1637 
1638 void RNA_def_main_texts(BlenderRNA *brna, PropertyRNA *cprop)
1639 {
1640   StructRNA *srna;
1641   FunctionRNA *func;
1642   PropertyRNA *parm;
1643 
1644   RNA_def_property_srna(cprop, "BlendDataTexts");
1645   srna = RNA_def_struct(brna, "BlendDataTexts", NULL);
1646   RNA_def_struct_sdna(srna, "Main");
1647   RNA_def_struct_ui_text(srna, "Main Texts", "Collection of texts");
1648 
1649   func = RNA_def_function(srna, "new", "rna_Main_texts_new");
1650   RNA_def_function_ui_description(func, "Add a new text to the main database");
1651   parm = RNA_def_string(func, "name", "Text", 0, "", "New name for the data-block");
1652   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1653   /* return type */
1654   parm = RNA_def_pointer(func, "text", "Text", "", "New text data-block");
1655   RNA_def_function_return(func, parm);
1656 
1657   func = RNA_def_function(srna, "remove", "rna_Main_ID_remove");
1658   RNA_def_function_ui_description(func, "Remove a text from the current blendfile");
1659   RNA_def_function_flag(func, FUNC_USE_REPORTS);
1660   parm = RNA_def_pointer(func, "text", "Text", "", "Text to remove");
1661   RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
1662   RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
1663   RNA_def_boolean(
1664       func, "do_unlink", true, "", "Unlink all usages of this text before deleting it");
1665   RNA_def_boolean(
1666       func, "do_id_user", true, "", "Decrement user counter of all datablocks used by this text");
1667   RNA_def_boolean(
1668       func, "do_ui_user", true, "", "Make sure interface does not reference this text");
1669 
1670   /* load func */
1671   func = RNA_def_function(srna, "load", "rna_Main_texts_load");
1672   RNA_def_function_flag(func, FUNC_USE_REPORTS);
1673   RNA_def_function_ui_description(func, "Add a new text to the main database from a file");
1674   parm = RNA_def_string_file_path(
1675       func, "filepath", "Path", FILE_MAX, "", "path for the data-block");
1676   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1677   parm = RNA_def_boolean(
1678       func, "internal", 0, "Make internal", "Make text file internal after loading");
1679   /* return type */
1680   parm = RNA_def_pointer(func, "text", "Text", "", "New text data-block");
1681   RNA_def_function_return(func, parm);
1682 
1683   func = RNA_def_function(srna, "tag", "rna_Main_texts_tag");
1684   parm = RNA_def_boolean(func, "value", 0, "Value", "");
1685   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1686 }
1687 
1688 void RNA_def_main_sounds(BlenderRNA *brna, PropertyRNA *cprop)
1689 {
1690   StructRNA *srna;
1691   FunctionRNA *func;
1692   PropertyRNA *parm;
1693 
1694   RNA_def_property_srna(cprop, "BlendDataSounds");
1695   srna = RNA_def_struct(brna, "BlendDataSounds", NULL);
1696   RNA_def_struct_sdna(srna, "Main");
1697   RNA_def_struct_ui_text(srna, "Main Sounds", "Collection of sounds");
1698 
1699   /* load func */
1700   func = RNA_def_function(srna, "load", "rna_Main_sounds_load");
1701   RNA_def_function_ui_description(func, "Add a new sound to the main database from a file");
1702   parm = RNA_def_string_file_path(
1703       func, "filepath", "Path", FILE_MAX, "", "path for the data-block");
1704   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1705   RNA_def_boolean(func,
1706                   "check_existing",
1707                   false,
1708                   "",
1709                   "Using existing data-block if this file is already loaded");
1710   /* return type */
1711   parm = RNA_def_pointer(func, "sound", "Sound", "", "New text data-block");
1712   RNA_def_function_return(func, parm);
1713 
1714   func = RNA_def_function(srna, "remove", "rna_Main_ID_remove");
1715   RNA_def_function_flag(func, FUNC_USE_REPORTS);
1716   RNA_def_function_ui_description(func, "Remove a sound from the current blendfile");
1717   parm = RNA_def_pointer(func, "sound", "Sound", "", "Sound to remove");
1718   RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
1719   RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
1720   RNA_def_boolean(
1721       func, "do_unlink", true, "", "Unlink all usages of this sound before deleting it");
1722   RNA_def_boolean(
1723       func, "do_id_user", true, "", "Decrement user counter of all datablocks used by this sound");
1724   RNA_def_boolean(
1725       func, "do_ui_user", true, "", "Make sure interface does not reference this sound");
1726 
1727   func = RNA_def_function(srna, "tag", "rna_Main_sounds_tag");
1728   parm = RNA_def_boolean(func, "value", 0, "Value", "");
1729   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1730 }
1731 
1732 void RNA_def_main_armatures(BlenderRNA *brna, PropertyRNA *cprop)
1733 {
1734   StructRNA *srna;
1735   FunctionRNA *func;
1736   PropertyRNA *parm;
1737 
1738   RNA_def_property_srna(cprop, "BlendDataArmatures");
1739   srna = RNA_def_struct(brna, "BlendDataArmatures", NULL);
1740   RNA_def_struct_sdna(srna, "Main");
1741   RNA_def_struct_ui_text(srna, "Main Armatures", "Collection of armatures");
1742 
1743   func = RNA_def_function(srna, "new", "rna_Main_armatures_new");
1744   RNA_def_function_ui_description(func, "Add a new armature to the main database");
1745   parm = RNA_def_string(func, "name", "Armature", 0, "", "New name for the data-block");
1746   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1747   /* return type */
1748   parm = RNA_def_pointer(func, "armature", "Armature", "", "New armature data-block");
1749   RNA_def_function_return(func, parm);
1750 
1751   func = RNA_def_function(srna, "remove", "rna_Main_ID_remove");
1752   RNA_def_function_flag(func, FUNC_USE_REPORTS);
1753   RNA_def_function_ui_description(func, "Remove a armature from the current blendfile");
1754   parm = RNA_def_pointer(func, "armature", "Armature", "", "Armature to remove");
1755   RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
1756   RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
1757   RNA_def_boolean(func,
1758                   "do_unlink",
1759                   true,
1760                   "",
1761                   "Unlink all usages of this armature before deleting it "
1762                   "(WARNING: will also delete objects instancing that armature data)");
1763   RNA_def_boolean(func,
1764                   "do_id_user",
1765                   true,
1766                   "",
1767                   "Decrement user counter of all datablocks used by this armature data");
1768   RNA_def_boolean(
1769       func, "do_ui_user", true, "", "Make sure interface does not reference this armature data");
1770 
1771   func = RNA_def_function(srna, "tag", "rna_Main_armatures_tag");
1772   parm = RNA_def_boolean(func, "value", 0, "Value", "");
1773   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1774 }
1775 void RNA_def_main_actions(BlenderRNA *brna, PropertyRNA *cprop)
1776 {
1777   StructRNA *srna;
1778   FunctionRNA *func;
1779   PropertyRNA *parm;
1780 
1781   RNA_def_property_srna(cprop, "BlendDataActions");
1782   srna = RNA_def_struct(brna, "BlendDataActions", NULL);
1783   RNA_def_struct_sdna(srna, "Main");
1784   RNA_def_struct_ui_text(srna, "Main Actions", "Collection of actions");
1785 
1786   func = RNA_def_function(srna, "new", "rna_Main_actions_new");
1787   RNA_def_function_ui_description(func, "Add a new action to the main database");
1788   parm = RNA_def_string(func, "name", "Action", 0, "", "New name for the data-block");
1789   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1790   /* return type */
1791   parm = RNA_def_pointer(func, "action", "Action", "", "New action data-block");
1792   RNA_def_function_return(func, parm);
1793 
1794   func = RNA_def_function(srna, "remove", "rna_Main_ID_remove");
1795   RNA_def_function_flag(func, FUNC_USE_REPORTS);
1796   RNA_def_function_ui_description(func, "Remove a action from the current blendfile");
1797   parm = RNA_def_pointer(func, "action", "Action", "", "Action to remove");
1798   RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
1799   RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
1800   RNA_def_boolean(
1801       func, "do_unlink", true, "", "Unlink all usages of this action before deleting it");
1802   RNA_def_boolean(func,
1803                   "do_id_user",
1804                   true,
1805                   "",
1806                   "Decrement user counter of all datablocks used by this action");
1807   RNA_def_boolean(
1808       func, "do_ui_user", true, "", "Make sure interface does not reference this action");
1809 
1810   func = RNA_def_function(srna, "tag", "rna_Main_actions_tag");
1811   parm = RNA_def_boolean(func, "value", 0, "Value", "");
1812   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1813 }
1814 void RNA_def_main_particles(BlenderRNA *brna, PropertyRNA *cprop)
1815 {
1816   StructRNA *srna;
1817   FunctionRNA *func;
1818   PropertyRNA *parm;
1819 
1820   RNA_def_property_srna(cprop, "BlendDataParticles");
1821   srna = RNA_def_struct(brna, "BlendDataParticles", NULL);
1822   RNA_def_struct_sdna(srna, "Main");
1823   RNA_def_struct_ui_text(srna, "Main Particle Settings", "Collection of particle settings");
1824 
1825   func = RNA_def_function(srna, "new", "rna_Main_particles_new");
1826   RNA_def_function_ui_description(func,
1827                                   "Add a new particle settings instance to the main database");
1828   parm = RNA_def_string(func, "name", "ParticleSettings", 0, "", "New name for the data-block");
1829   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1830   /* return type */
1831   parm = RNA_def_pointer(
1832       func, "particle", "ParticleSettings", "", "New particle settings data-block");
1833   RNA_def_function_return(func, parm);
1834 
1835   func = RNA_def_function(srna, "remove", "rna_Main_ID_remove");
1836   RNA_def_function_flag(func, FUNC_USE_REPORTS);
1837   RNA_def_function_ui_description(
1838       func, "Remove a particle settings instance from the current blendfile");
1839   parm = RNA_def_pointer(func, "particle", "ParticleSettings", "", "Particle Settings to remove");
1840   RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
1841   RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
1842   RNA_def_boolean(func,
1843                   "do_unlink",
1844                   true,
1845                   "",
1846                   "Unlink all usages of those particle settings before deleting them");
1847   RNA_def_boolean(func,
1848                   "do_id_user",
1849                   true,
1850                   "",
1851                   "Decrement user counter of all datablocks used by this particle settings");
1852   RNA_def_boolean(func,
1853                   "do_ui_user",
1854                   true,
1855                   "",
1856                   "Make sure interface does not reference this particle settings");
1857 
1858   func = RNA_def_function(srna, "tag", "rna_Main_particles_tag");
1859   parm = RNA_def_boolean(func, "value", 0, "Value", "");
1860   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1861 }
1862 
1863 void RNA_def_main_palettes(BlenderRNA *brna, PropertyRNA *cprop)
1864 {
1865   StructRNA *srna;
1866   FunctionRNA *func;
1867   PropertyRNA *parm;
1868 
1869   RNA_def_property_srna(cprop, "BlendDataPalettes");
1870   srna = RNA_def_struct(brna, "BlendDataPalettes", NULL);
1871   RNA_def_struct_sdna(srna, "Main");
1872   RNA_def_struct_ui_text(srna, "Main Palettes", "Collection of palettes");
1873 
1874   func = RNA_def_function(srna, "new", "rna_Main_palettes_new");
1875   RNA_def_function_ui_description(func, "Add a new palette to the main database");
1876   parm = RNA_def_string(func, "name", "Palette", 0, "", "New name for the data-block");
1877   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1878   /* return type */
1879   parm = RNA_def_pointer(func, "palette", "Palette", "", "New palette data-block");
1880   RNA_def_function_return(func, parm);
1881 
1882   func = RNA_def_function(srna, "remove", "rna_Main_ID_remove");
1883   RNA_def_function_flag(func, FUNC_USE_REPORTS);
1884   RNA_def_function_ui_description(func, "Remove a palette from the current blendfile");
1885   parm = RNA_def_pointer(func, "palette", "Palette", "", "Palette to remove");
1886   RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
1887   RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
1888   RNA_def_boolean(
1889       func, "do_unlink", true, "", "Unlink all usages of this palette before deleting it");
1890   RNA_def_boolean(func,
1891                   "do_id_user",
1892                   true,
1893                   "",
1894                   "Decrement user counter of all datablocks used by this palette");
1895   RNA_def_boolean(
1896       func, "do_ui_user", true, "", "Make sure interface does not reference this palette");
1897 
1898   func = RNA_def_function(srna, "tag", "rna_Main_palettes_tag");
1899   parm = RNA_def_boolean(func, "value", 0, "Value", "");
1900   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1901 }
1902 void RNA_def_main_cachefiles(BlenderRNA *brna, PropertyRNA *cprop)
1903 {
1904   StructRNA *srna;
1905   FunctionRNA *func;
1906   PropertyRNA *parm;
1907 
1908   RNA_def_property_srna(cprop, "BlendDataCacheFiles");
1909   srna = RNA_def_struct(brna, "BlendDataCacheFiles", NULL);
1910   RNA_def_struct_sdna(srna, "Main");
1911   RNA_def_struct_ui_text(srna, "Main Cache Files", "Collection of cache files");
1912 
1913   func = RNA_def_function(srna, "tag", "rna_Main_cachefiles_tag");
1914   parm = RNA_def_boolean(func, "value", 0, "Value", "");
1915   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1916 }
1917 void RNA_def_main_paintcurves(BlenderRNA *brna, PropertyRNA *cprop)
1918 {
1919   StructRNA *srna;
1920   FunctionRNA *func;
1921   PropertyRNA *parm;
1922 
1923   RNA_def_property_srna(cprop, "BlendDataPaintCurves");
1924   srna = RNA_def_struct(brna, "BlendDataPaintCurves", NULL);
1925   RNA_def_struct_sdna(srna, "Main");
1926   RNA_def_struct_ui_text(srna, "Main Paint Curves", "Collection of paint curves");
1927 
1928   func = RNA_def_function(srna, "tag", "rna_Main_paintcurves_tag");
1929   parm = RNA_def_boolean(func, "value", 0, "Value", "");
1930   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1931 }
1932 void RNA_def_main_gpencil(BlenderRNA *brna, PropertyRNA *cprop)
1933 {
1934   StructRNA *srna;
1935   FunctionRNA *func;
1936   PropertyRNA *parm;
1937 
1938   RNA_def_property_srna(cprop, "BlendDataGreasePencils");
1939   srna = RNA_def_struct(brna, "BlendDataGreasePencils", NULL);
1940   RNA_def_struct_sdna(srna, "Main");
1941   RNA_def_struct_ui_text(srna, "Main Grease Pencils", "Collection of grease pencils");
1942 
1943   func = RNA_def_function(srna, "tag", "rna_Main_gpencils_tag");
1944   parm = RNA_def_boolean(func, "value", 0, "Value", "");
1945   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1946 
1947   func = RNA_def_function(srna, "new", "rna_Main_gpencils_new");
1948   RNA_def_function_ui_description(func, "Add a new grease pencil datablock to the main database");
1949   parm = RNA_def_string(func, "name", "GreasePencil", 0, "", "New name for the data-block");
1950   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1951   /* return type */
1952   parm = RNA_def_pointer(
1953       func, "grease_pencil", "GreasePencil", "", "New grease pencil data-block");
1954   RNA_def_function_return(func, parm);
1955 
1956   func = RNA_def_function(srna, "remove", "rna_Main_ID_remove");
1957   RNA_def_function_flag(func, FUNC_USE_REPORTS);
1958   RNA_def_function_ui_description(func,
1959                                   "Remove a grease pencil instance from the current blendfile");
1960   parm = RNA_def_pointer(func, "grease_pencil", "GreasePencil", "", "Grease Pencil to remove");
1961   RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
1962   RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
1963   RNA_def_boolean(
1964       func, "do_unlink", true, "", "Unlink all usages of this grease pencil before deleting it");
1965   RNA_def_boolean(func,
1966                   "do_id_user",
1967                   true,
1968                   "",
1969                   "Decrement user counter of all datablocks used by this grease pencil");
1970   RNA_def_boolean(
1971       func, "do_ui_user", true, "", "Make sure interface does not reference this grease pencil");
1972 }
1973 
1974 void RNA_def_main_movieclips(BlenderRNA *brna, PropertyRNA *cprop)
1975 {
1976   StructRNA *srna;
1977   FunctionRNA *func;
1978   PropertyRNA *parm;
1979 
1980   RNA_def_property_srna(cprop, "BlendDataMovieClips");
1981   srna = RNA_def_struct(brna, "BlendDataMovieClips", NULL);
1982   RNA_def_struct_sdna(srna, "Main");
1983   RNA_def_struct_ui_text(srna, "Main Movie Clips", "Collection of movie clips");
1984 
1985   func = RNA_def_function(srna, "tag", "rna_Main_movieclips_tag");
1986   parm = RNA_def_boolean(func, "value", 0, "Value", "");
1987   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1988 
1989   func = RNA_def_function(srna, "remove", "rna_Main_ID_remove");
1990   RNA_def_function_flag(func, FUNC_USE_REPORTS);
1991   RNA_def_function_ui_description(func, "Remove a movie clip from the current blendfile.");
1992   parm = RNA_def_pointer(func, "clip", "MovieClip", "", "Movie clip to remove");
1993   RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
1994   RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
1995   RNA_def_boolean(
1996       func, "do_unlink", true, "", "Unlink all usages of this movie clip before deleting it");
1997   RNA_def_boolean(func,
1998                   "do_id_user",
1999                   true,
2000                   "",
2001                   "Decrement user counter of all datablocks used by this movie clip");
2002   RNA_def_boolean(
2003       func, "do_ui_user", true, "", "Make sure interface does not reference this movie clip");
2004 
2005   /* load func */
2006   func = RNA_def_function(srna, "load", "rna_Main_movieclip_load");
2007   RNA_def_function_flag(func, FUNC_USE_REPORTS);
2008   RNA_def_function_ui_description(
2009       func,
2010       "Add a new movie clip to the main database from a file "
2011       "(while ``check_existing`` is disabled for consistency with other load functions, "
2012       "behavior with multiple movie-clips using the same file may incorrectly generate proxies)");
2013   parm = RNA_def_string_file_path(
2014       func, "filepath", "Path", FILE_MAX, "", "path for the data-block");
2015   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
2016   RNA_def_boolean(func,
2017                   "check_existing",
2018                   false,
2019                   "",
2020                   "Using existing data-block if this file is already loaded");
2021   /* return type */
2022   parm = RNA_def_pointer(func, "clip", "MovieClip", "", "New movie clip data-block");
2023   RNA_def_function_return(func, parm);
2024 }
2025 
2026 void RNA_def_main_masks(BlenderRNA *brna, PropertyRNA *cprop)
2027 {
2028   StructRNA *srna;
2029   FunctionRNA *func;
2030   PropertyRNA *parm;
2031 
2032   RNA_def_property_srna(cprop, "BlendDataMasks");
2033   srna = RNA_def_struct(brna, "BlendDataMasks", NULL);
2034   RNA_def_struct_sdna(srna, "Main");
2035   RNA_def_struct_ui_text(srna, "Main Masks", "Collection of masks");
2036 
2037   func = RNA_def_function(srna, "tag", "rna_Main_masks_tag");
2038   parm = RNA_def_boolean(func, "value", 0, "Value", "");
2039   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
2040 
2041   /* new func */
2042   func = RNA_def_function(srna, "new", "rna_Main_mask_new");
2043   RNA_def_function_ui_description(func, "Add a new mask with a given name to the main database");
2044   parm = RNA_def_string(
2045       func, "name", NULL, MAX_ID_NAME - 2, "Mask", "Name of new mask data-block");
2046   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
2047   /* return type */
2048   parm = RNA_def_pointer(func, "mask", "Mask", "", "New mask data-block");
2049   RNA_def_function_return(func, parm);
2050 
2051   /* remove func */
2052   func = RNA_def_function(srna, "remove", "rna_Main_ID_remove");
2053   RNA_def_function_flag(func, FUNC_USE_REPORTS);
2054   RNA_def_function_ui_description(func, "Remove a masks from the current blendfile.");
2055   parm = RNA_def_pointer(func, "mask", "Mask", "", "Mask to remove");
2056   RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
2057   RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
2058   RNA_def_boolean(
2059       func, "do_unlink", true, "", "Unlink all usages of this mask before deleting it");
2060   RNA_def_boolean(
2061       func, "do_id_user", true, "", "Decrement user counter of all datablocks used by this mask");
2062   RNA_def_boolean(
2063       func, "do_ui_user", true, "", "Make sure interface does not reference this mask");
2064 }
2065 
2066 void RNA_def_main_linestyles(BlenderRNA *brna, PropertyRNA *cprop)
2067 {
2068   StructRNA *srna;
2069   FunctionRNA *func;
2070   PropertyRNA *parm;
2071 
2072   RNA_def_property_srna(cprop, "BlendDataLineStyles");
2073   srna = RNA_def_struct(brna, "BlendDataLineStyles", NULL);
2074   RNA_def_struct_sdna(srna, "Main");
2075   RNA_def_struct_ui_text(srna, "Main Line Styles", "Collection of line styles");
2076 
2077   func = RNA_def_function(srna, "tag", "rna_Main_linestyle_tag");
2078   parm = RNA_def_boolean(func, "value", 0, "Value", "");
2079   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
2080 
2081   func = RNA_def_function(srna, "new", "rna_Main_linestyles_new");
2082   RNA_def_function_ui_description(func, "Add a new line style instance to the main database");
2083   parm = RNA_def_string(func, "name", "FreestyleLineStyle", 0, "", "New name for the data-block");
2084   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
2085   /* return type */
2086   parm = RNA_def_pointer(func, "linestyle", "FreestyleLineStyle", "", "New line style data-block");
2087   RNA_def_function_return(func, parm);
2088 
2089   func = RNA_def_function(srna, "remove", "rna_Main_ID_remove");
2090   RNA_def_function_flag(func, FUNC_USE_REPORTS);
2091   RNA_def_function_ui_description(func, "Remove a line style instance from the current blendfile");
2092   parm = RNA_def_pointer(func, "linestyle", "FreestyleLineStyle", "", "Line style to remove");
2093   RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
2094   RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
2095   RNA_def_boolean(
2096       func, "do_unlink", true, "", "Unlink all usages of this line style before deleting it");
2097   RNA_def_boolean(func,
2098                   "do_id_user",
2099                   true,
2100                   "",
2101                   "Decrement user counter of all datablocks used by this line style");
2102   RNA_def_boolean(
2103       func, "do_ui_user", true, "", "Make sure interface does not reference this line style");
2104 }
2105 
2106 void RNA_def_main_workspaces(BlenderRNA *brna, PropertyRNA *cprop)
2107 {
2108   StructRNA *srna;
2109   FunctionRNA *func;
2110   PropertyRNA *parm;
2111 
2112   RNA_def_property_srna(cprop, "BlendDataWorkSpaces");
2113   srna = RNA_def_struct(brna, "BlendDataWorkSpaces", NULL);
2114   RNA_def_struct_sdna(srna, "Main");
2115   RNA_def_struct_ui_text(srna, "Main Workspaces", "Collection of workspaces");
2116 
2117   func = RNA_def_function(srna, "tag", "rna_Main_workspaces_tag");
2118   parm = RNA_def_boolean(func, "value", 0, "Value", "");
2119   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
2120 }
2121 
2122 void RNA_def_main_lightprobes(BlenderRNA *brna, PropertyRNA *cprop)
2123 {
2124   StructRNA *srna;
2125   FunctionRNA *func;
2126   PropertyRNA *parm;
2127 
2128   RNA_def_property_srna(cprop, "BlendDataProbes");
2129   srna = RNA_def_struct(brna, "BlendDataProbes", NULL);
2130   RNA_def_struct_sdna(srna, "Main");
2131   RNA_def_struct_ui_text(srna, "Main Light Probes", "Collection of light probes");
2132 
2133   func = RNA_def_function(srna, "new", "rna_Main_lightprobe_new");
2134   RNA_def_function_ui_description(func, "Add a new probe to the main database");
2135   parm = RNA_def_string(func, "name", "Probe", 0, "", "New name for the data-block");
2136   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
2137   parm = RNA_def_enum(
2138       func, "type", rna_enum_lightprobes_type_items, 0, "Type", "The type of lightprobe to add");
2139   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
2140   /* return type */
2141   parm = RNA_def_pointer(func, "lightprobe", "LightProbe", "", "New light probe data-block");
2142   RNA_def_function_return(func, parm);
2143 
2144   func = RNA_def_function(srna, "remove", "rna_Main_ID_remove");
2145   RNA_def_function_flag(func, FUNC_USE_REPORTS);
2146   RNA_def_function_ui_description(func, "Remove a probe from the current blendfile");
2147   parm = RNA_def_pointer(func, "lightprobe", "LightProbe", "", "Probe to remove");
2148   RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
2149   RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
2150   RNA_def_boolean(func,
2151                   "do_unlink",
2152                   true,
2153                   "",
2154                   "Unlink all usages of this probe before deleting it "
2155                   "(WARNING: will also delete objects instancing that light probe data)");
2156   RNA_def_boolean(func,
2157                   "do_id_user",
2158                   true,
2159                   "",
2160                   "Decrement user counter of all datablocks used by this light probe");
2161   RNA_def_boolean(
2162       func, "do_ui_user", true, "", "Make sure interface does not reference this light probe");
2163 
2164   func = RNA_def_function(srna, "tag", "rna_Main_lightprobes_tag");
2165   parm = RNA_def_boolean(func, "value", 0, "Value", "");
2166   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
2167 }
2168 
2169 #  ifdef WITH_HAIR_NODES
2170 void RNA_def_main_hairs(BlenderRNA *brna, PropertyRNA *cprop)
2171 {
2172   StructRNA *srna;
2173   FunctionRNA *func;
2174   PropertyRNA *parm;
2175 
2176   RNA_def_property_srna(cprop, "BlendDataHairs");
2177   srna = RNA_def_struct(brna, "BlendDataHairs", NULL);
2178   RNA_def_struct_sdna(srna, "Main");
2179   RNA_def_struct_ui_text(srna, "Main Hairs", "Collection of hairs");
2180 
2181   func = RNA_def_function(srna, "new", "rna_Main_hairs_new");
2182   RNA_def_function_ui_description(func, "Add a new hair to the main database");
2183   parm = RNA_def_string(func, "name", "Hair", 0, "", "New name for the data-block");
2184   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
2185   /* return type */
2186   parm = RNA_def_pointer(func, "hair", "Hair", "", "New hair data-block");
2187   RNA_def_function_return(func, parm);
2188 
2189   func = RNA_def_function(srna, "remove", "rna_Main_ID_remove");
2190   RNA_def_function_flag(func, FUNC_USE_REPORTS);
2191   RNA_def_function_ui_description(func, "Remove a hair from the current blendfile");
2192   parm = RNA_def_pointer(func, "hair", "Hair", "", "Hair to remove");
2193   RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
2194   RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
2195   RNA_def_boolean(func,
2196                   "do_unlink",
2197                   true,
2198                   "",
2199                   "Unlink all usages of this hair before deleting it "
2200                   "(WARNING: will also delete objects instancing that hair data)");
2201   RNA_def_boolean(func,
2202                   "do_id_user",
2203                   true,
2204                   "",
2205                   "Decrement user counter of all datablocks used by this hair data");
2206   RNA_def_boolean(
2207       func, "do_ui_user", true, "", "Make sure interface does not reference this hair data");
2208 
2209   func = RNA_def_function(srna, "tag", "rna_Main_hairs_tag");
2210   parm = RNA_def_boolean(func, "value", 0, "Value", "");
2211   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
2212 }
2213 #  endif
2214 
2215 #  ifdef WITH_POINT_CLOUD
2216 void RNA_def_main_pointclouds(BlenderRNA *brna, PropertyRNA *cprop)
2217 {
2218   StructRNA *srna;
2219   FunctionRNA *func;
2220   PropertyRNA *parm;
2221 
2222   RNA_def_property_srna(cprop, "BlendDataPointClouds");
2223   srna = RNA_def_struct(brna, "BlendDataPointClouds", NULL);
2224   RNA_def_struct_sdna(srna, "Main");
2225   RNA_def_struct_ui_text(srna, "Main Point Clouds", "Collection of point clouds");
2226 
2227   func = RNA_def_function(srna, "new", "rna_Main_pointclouds_new");
2228   RNA_def_function_ui_description(func, "Add a new point cloud to the main database");
2229   parm = RNA_def_string(func, "name", "PointCloud", 0, "", "New name for the data-block");
2230   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
2231   /* return type */
2232   parm = RNA_def_pointer(func, "pointcloud", "PointCloud", "", "New point cloud data-block");
2233   RNA_def_function_return(func, parm);
2234 
2235   func = RNA_def_function(srna, "remove", "rna_Main_ID_remove");
2236   RNA_def_function_flag(func, FUNC_USE_REPORTS);
2237   RNA_def_function_ui_description(func, "Remove a point cloud from the current blendfile");
2238   parm = RNA_def_pointer(func, "pointcloud", "PointCloud", "", "Point cloud to remove");
2239   RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
2240   RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
2241   RNA_def_boolean(func,
2242                   "do_unlink",
2243                   true,
2244                   "",
2245                   "Unlink all usages of this point cloud before deleting it "
2246                   "(WARNING: will also delete objects instancing that point cloud data)");
2247   RNA_def_boolean(func,
2248                   "do_id_user",
2249                   true,
2250                   "",
2251                   "Decrement user counter of all datablocks used by this point cloud data");
2252   RNA_def_boolean(func,
2253                   "do_ui_user",
2254                   true,
2255                   "",
2256                   "Make sure interface does not reference this point cloud data");
2257 
2258   func = RNA_def_function(srna, "tag", "rna_Main_pointclouds_tag");
2259   parm = RNA_def_boolean(func, "value", 0, "Value", "");
2260   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
2261 }
2262 #  endif
2263 
2264 void RNA_def_main_volumes(BlenderRNA *brna, PropertyRNA *cprop)
2265 {
2266   StructRNA *srna;
2267   FunctionRNA *func;
2268   PropertyRNA *parm;
2269 
2270   RNA_def_property_srna(cprop, "BlendDataVolumes");
2271   srna = RNA_def_struct(brna, "BlendDataVolumes", NULL);
2272   RNA_def_struct_sdna(srna, "Main");
2273   RNA_def_struct_ui_text(srna, "Main Volumes", "Collection of volumes");
2274 
2275   func = RNA_def_function(srna, "new", "rna_Main_volumes_new");
2276   RNA_def_function_ui_description(func, "Add a new volume to the main database");
2277   parm = RNA_def_string(func, "name", "Volume", 0, "", "New name for the data-block");
2278   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
2279   /* return type */
2280   parm = RNA_def_pointer(func, "volume", "Volume", "", "New volume data-block");
2281   RNA_def_function_return(func, parm);
2282 
2283   func = RNA_def_function(srna, "remove", "rna_Main_ID_remove");
2284   RNA_def_function_flag(func, FUNC_USE_REPORTS);
2285   RNA_def_function_ui_description(func, "Remove a volume from the current blendfile");
2286   parm = RNA_def_pointer(func, "volume", "Volume", "", "Volume to remove");
2287   RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
2288   RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
2289   RNA_def_boolean(func,
2290                   "do_unlink",
2291                   true,
2292                   "",
2293                   "Unlink all usages of this volume before deleting it "
2294                   "(WARNING: will also delete objects instancing that volume data)");
2295   RNA_def_boolean(func,
2296                   "do_id_user",
2297                   true,
2298                   "",
2299                   "Decrement user counter of all datablocks used by this volume data");
2300   RNA_def_boolean(
2301       func, "do_ui_user", true, "", "Make sure interface does not reference this volume data");
2302 
2303   func = RNA_def_function(srna, "tag", "rna_Main_volumes_tag");
2304   parm = RNA_def_boolean(func, "value", 0, "Value", "");
2305   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
2306 }
2307 
2308 #  ifdef WITH_GEOMETRY_NODES
2309 void RNA_def_main_simulations(BlenderRNA *brna, PropertyRNA *cprop)
2310 {
2311   StructRNA *srna;
2312   FunctionRNA *func;
2313   PropertyRNA *parm;
2314 
2315   RNA_def_property_srna(cprop, "BlendDataSimulations");
2316   srna = RNA_def_struct(brna, "BlendDataSimulations", NULL);
2317   RNA_def_struct_sdna(srna, "Main");
2318   RNA_def_struct_ui_text(srna, "Main Simulations", "Collection of simulations");
2319 
2320   func = RNA_def_function(srna, "new", "rna_Main_simulations_new");
2321   RNA_def_function_ui_description(func, "Add a new simulation to the main database");
2322   parm = RNA_def_string(func, "name", "Simulation", 0, "", "New name for the data-block");
2323   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
2324   /* return type */
2325   parm = RNA_def_pointer(func, "simulation", "Simulation", "", "New simulation data-block");
2326   RNA_def_function_return(func, parm);
2327 
2328   func = RNA_def_function(srna, "remove", "rna_Main_ID_remove");
2329   RNA_def_function_flag(func, FUNC_USE_REPORTS);
2330   RNA_def_function_ui_description(func, "Remove a simulation from the current blendfile");
2331   parm = RNA_def_pointer(func, "simulation", "Simulation", "", "Simulation to remove");
2332   RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
2333   RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
2334   RNA_def_boolean(
2335       func, "do_unlink", true, "", "Unlink all usages of this simulation before deleting it");
2336   RNA_def_boolean(func,
2337                   "do_id_user",
2338                   true,
2339                   "",
2340                   "Decrement user counter of all datablocks used by this simulation data");
2341   RNA_def_boolean(
2342       func, "do_ui_user", true, "", "Make sure interface does not reference this simulation data");
2343 
2344   func = RNA_def_function(srna, "tag", "rna_Main_simulations_tag");
2345   parm = RNA_def_boolean(func, "value", 0, "Value", "");
2346   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
2347 }
2348 #  endif
2349 
2350 #endif
2351