2 * ***** BEGIN GPL LICENSE BLOCK *****
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
19 * All rights reserved.
21 * Contributor(s): Blender Foundation, 2002-2008 full recode
23 * ***** END GPL LICENSE BLOCK *****
26 /** \file blender/editors/object/object_select.c
36 #include "MEM_guardedalloc.h"
38 #include "DNA_anim_types.h"
39 #include "DNA_group_types.h"
40 #include "DNA_material_types.h"
41 #include "DNA_modifier_types.h"
42 #include "DNA_property_types.h"
43 #include "DNA_scene_types.h"
44 #include "DNA_armature_types.h"
47 #include "BLI_listbase.h"
49 #include "BLI_string.h"
50 #include "BLI_utildefines.h"
52 #include "BKE_context.h"
53 #include "BKE_group.h"
55 #include "BKE_material.h"
56 #include "BKE_particle.h"
57 #include "BKE_property.h"
58 #include "BKE_report.h"
59 #include "BKE_scene.h"
60 #include "BKE_library.h"
61 #include "BKE_deform.h"
66 #include "ED_object.h"
67 #include "ED_screen.h"
68 #include "ED_keyframing.h"
70 #include "UI_interface.h"
71 #include "UI_resources.h"
73 #include "RNA_access.h"
74 #include "RNA_define.h"
75 #include "RNA_enum_types.h"
77 #include "object_intern.h"
79 /************************ Exported **************************/
81 /* simple API for object selection, rather than just using the flag
82 * this takes into account the 'restrict selection in 3d view' flag.
83 * deselect works always, the restriction just prevents selection */
85 /* Note: send a NC_SCENE|ND_OB_SELECT notifier yourself! (or
86 * or a NC_SCENE|ND_OB_VISIBLE in case of visibility toggling */
88 void ED_base_object_select(Base *base, short mode)
91 if (mode==BA_SELECT) {
92 if (!(base->object->restrictflag & OB_RESTRICT_SELECT))
95 else if (mode==BA_DESELECT) {
96 base->flag &= ~SELECT;
98 base->object->flag= base->flag;
102 /* also to set active NULL */
103 void ED_base_object_activate(bContext *C, Base *base)
105 Scene *scene= CTX_data_scene(C);
107 /* sets scene->basact */
112 /* XXX old signals, remember to handle notifiers now! */
113 // select_actionchannel_by_name(base->object->action, "Object", 1);
115 WM_event_add_notifier(C, NC_SCENE|ND_OB_ACTIVE, scene);
118 WM_event_add_notifier(C, NC_SCENE|ND_OB_ACTIVE, NULL);
121 /********************** Selection Operators **********************/
123 static int objects_selectable_poll(bContext *C)
125 /* we don't check for linked scenes here, selection is
126 still allowed then for inspection of scene */
127 Object *obact= CTX_data_active_object(C);
129 if(CTX_data_edit_object(C))
131 if(obact && obact->mode)
137 /************************ Select by Type *************************/
139 static int object_select_by_type_exec(bContext *C, wmOperator *op)
141 short obtype, extend;
143 obtype = RNA_enum_get(op->ptr, "type");
144 extend= RNA_boolean_get(op->ptr, "extend");
147 CTX_DATA_BEGIN(C, Base*, base, visible_bases) {
148 ED_base_object_select(base, BA_DESELECT);
153 CTX_DATA_BEGIN(C, Base*, base, visible_bases) {
154 if(base->object->type==obtype) {
155 ED_base_object_select(base, BA_SELECT);
160 WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, CTX_data_scene(C));
162 return OPERATOR_FINISHED;
165 void OBJECT_OT_select_by_type(wmOperatorType *ot)
168 ot->name= "Select By Type";
169 ot->description = "Select all visible objects that are of a type";
170 ot->idname= "OBJECT_OT_select_by_type";
173 ot->invoke= WM_menu_invoke;
174 ot->exec= object_select_by_type_exec;
175 ot->poll= objects_selectable_poll;
178 ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
181 RNA_def_boolean(ot->srna, "extend", FALSE, "Extend", "Extend selection instead of deselecting everything first");
182 ot->prop= RNA_def_enum(ot->srna, "type", object_type_items, 1, "Type", "");
185 /*********************** Selection by Links *********************/
187 static EnumPropertyItem prop_select_linked_types[] = {
188 //{1, "IPO", 0, "Object IPO", ""}, // XXX depreceated animation system stuff...
189 {2, "OBDATA", 0, "Object Data", ""},
190 {3, "MATERIAL", 0, "Material", ""},
191 {4, "TEXTURE", 0, "Texture", ""},
192 {5, "DUPGROUP", 0, "Dupligroup", ""},
193 {6, "PARTICLE", 0, "Particle System", ""},
194 {7, "LIBRARY", 0, "Library", ""},
195 {8, "LIBRARY_OBDATA", 0, "Library (Object Data)", ""},
196 {0, NULL, 0, NULL, NULL}
199 static int object_select_linked_exec(bContext *C, wmOperator *op)
201 Scene *scene= CTX_data_scene(C);
204 Material *mat = NULL, *mat1;
207 int nr = RNA_enum_get(op->ptr, "type");
208 short changed = 0, extend;
212 * Current Material: 3
218 extend= RNA_boolean_get(op->ptr, "extend");
221 CTX_DATA_BEGIN(C, Base*, base, visible_bases) {
222 ED_base_object_select(base, BA_DESELECT);
229 BKE_report(op->reports, RPT_ERROR, "No Active Object");
230 return OPERATOR_CANCELLED;
234 // XXX old animation system
236 //if(ipo==0) return OPERATOR_CANCELLED;
237 return OPERATOR_CANCELLED;
240 if(ob->data==NULL) return OPERATOR_CANCELLED;
243 else if(nr==3 || nr==4) {
244 mat= give_current_material(ob, ob->actcol);
245 if(mat==NULL) return OPERATOR_CANCELLED;
247 if(mat->mtex[ (int)mat->texact ]) tex= mat->mtex[ (int)mat->texact ]->tex;
248 if(tex==NULL) return OPERATOR_CANCELLED;
252 if(ob->dup_group==NULL) return OPERATOR_CANCELLED;
255 if(ob->particlesystem.first==NULL) return OPERATOR_CANCELLED;
261 if(ob->data==NULL) return OPERATOR_CANCELLED;
264 return OPERATOR_CANCELLED;
266 CTX_DATA_BEGIN(C, Base*, base, visible_bases) {
268 // XXX old animation system
269 //if(base->object->ipo==ipo) base->flag |= SELECT;
273 if(base->object->data==obdata) base->flag |= SELECT;
276 else if(nr==3 || nr==4) {
279 for(a=1; a<=ob->totcol; a++) {
280 mat1= give_current_material(ob, a);
282 if(mat1==mat) base->flag |= SELECT;
285 else if(mat1 && nr==4) {
286 for(b=0; b<MAX_MTEX; b++) {
288 if(tex==mat1->mtex[b]->tex) {
289 base->flag |= SELECT;
299 if(base->object->dup_group==ob->dup_group) {
300 base->flag |= SELECT;
305 /* loop through other, then actives particles*/
306 ParticleSystem *psys;
307 ParticleSystem *psys_act;
309 for(psys=base->object->particlesystem.first; psys; psys=psys->next) {
310 for(psys_act=ob->particlesystem.first; psys_act; psys_act=psys_act->next) {
311 if (psys->part == psys_act->part) {
312 base->flag |= SELECT;
318 if (base->flag & SELECT) {
324 if(ob->id.lib == base->object->id.lib) {
325 base->flag |= SELECT;
330 if(base->object->data && ((ID *)ob->data)->lib == ((ID *)base->object->data)->lib) {
331 base->flag |= SELECT;
335 base->object->flag= base->flag;
340 WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, CTX_data_scene(C));
341 return OPERATOR_FINISHED;
344 return OPERATOR_CANCELLED;
347 void OBJECT_OT_select_linked(wmOperatorType *ot)
350 ot->name= "Select Linked";
351 ot->description = "Select all visible objects that are linked";
352 ot->idname= "OBJECT_OT_select_linked";
355 ot->invoke= WM_menu_invoke;
356 ot->exec= object_select_linked_exec;
357 ot->poll= objects_selectable_poll;
360 ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
363 RNA_def_boolean(ot->srna, "extend", FALSE, "Extend", "Extend selection instead of deselecting everything first");
364 ot->prop= RNA_def_enum(ot->srna, "type", prop_select_linked_types, 0, "Type", "");
367 /*********************** Selected Grouped ********************/
369 static EnumPropertyItem prop_select_grouped_types[] = {
370 {1, "CHILDREN_RECURSIVE", 0, "Children", ""},
371 {2, "CHILDREN", 0, "Immediate Children", ""},
372 {3, "PARENT", 0, "Parent", ""},
373 {4, "SIBLINGS", 0, "Siblings", "Shared Parent"},
374 {5, "TYPE", 0, "Type", "Shared object type"},
375 {6, "LAYER", 0, "Layer", "Shared layers"},
376 {7, "GROUP", 0, "Group", "Shared group"},
377 {8, "HOOK", 0, "Hook", ""},
378 {9, "PASS", 0, "Pass", "Render pass Index"},
379 {10, "COLOR", 0, "Color", "Object Color"},
380 {11, "PROPERTIES", 0, "Properties", "Game Properties"},
381 {12, "KEYINGSET", 0, "Keying Set", "Objects included in active Keying Set"},
382 {0, NULL, 0, NULL, NULL}
385 static short select_grouped_children(bContext *C, Object *ob, int recursive)
389 CTX_DATA_BEGIN(C, Base*, base, selectable_bases) {
390 if (ob == base->object->parent) {
391 if (!(base->flag & SELECT)) {
392 ED_base_object_select(base, BA_SELECT);
397 changed |= select_grouped_children(C, base->object, 1);
404 static short select_grouped_parent(bContext *C) /* Makes parent active and de-selected OBACT */
406 Scene *scene= CTX_data_scene(C);
407 View3D *v3d= CTX_wm_view3d(C);
410 Base *baspar, *basact= CTX_data_active_base(C);
412 if (!basact || !(basact->object->parent)) return 0; /* we know OBACT is valid */
414 baspar= object_in_scene(basact->object->parent, scene);
416 /* can be NULL if parent in other scene */
417 if(baspar && BASE_SELECTABLE(v3d, baspar)) {
418 ED_base_object_select(basact, BA_DESELECT);
419 ED_base_object_select(baspar, BA_SELECT);
420 ED_base_object_activate(C, baspar);
427 #define GROUP_MENU_MAX 24
428 static short select_grouped_group(bContext *C, Object *ob) /* Select objects in the same group as the active */
431 Group *group, *ob_groups[GROUP_MENU_MAX];
432 int group_count=0, i;
436 for (group=CTX_data_main(C)->group.first; group && group_count < GROUP_MENU_MAX; group=group->id.next) {
437 if (object_in_group (ob, group)) {
438 ob_groups[group_count] = group;
445 else if (group_count == 1) {
446 group = ob_groups[0];
447 CTX_DATA_BEGIN(C, Base*, base, visible_bases) {
448 if (!(base->flag & SELECT) && object_in_group(base->object, group)) {
449 ED_base_object_select(base, BA_SELECT);
457 /* build the menu. */
458 pup= uiPupMenuBegin(C, "Select Group", ICON_NONE);
459 layout= uiPupMenuLayout(pup);
461 for (i=0; i<group_count; i++) {
462 group = ob_groups[i];
463 uiItemStringO(layout, group->id.name+2, 0, "OBJECT_OT_select_same_group", "group", group->id.name);
466 uiPupMenuEnd(C, pup);
467 return changed; // The operator already handle this!
470 static short select_grouped_object_hooks(bContext *C, Object *ob)
472 Scene *scene= CTX_data_scene(C);
473 View3D *v3d= CTX_wm_view3d(C);
478 HookModifierData *hmd;
480 for (md = ob->modifiers.first; md; md=md->next) {
481 if (md->type==eModifierType_Hook) {
482 hmd= (HookModifierData*) md;
483 if (hmd->object && !(hmd->object->flag & SELECT)) {
484 base= object_in_scene(hmd->object, scene);
485 if (base && (BASE_SELECTABLE(v3d, base))) {
486 ED_base_object_select(base, BA_SELECT);
495 /* Select objects woth the same parent as the active (siblings),
496 * parent can be NULL also */
497 static short select_grouped_siblings(bContext *C, Object *ob)
501 CTX_DATA_BEGIN(C, Base*, base, selectable_bases) {
502 if ((base->object->parent==ob->parent) && !(base->flag & SELECT)) {
503 ED_base_object_select(base, BA_SELECT);
511 static short select_grouped_type(bContext *C, Object *ob)
515 CTX_DATA_BEGIN(C, Base*, base, selectable_bases) {
516 if ((base->object->type == ob->type) && !(base->flag & SELECT)) {
517 ED_base_object_select(base, BA_SELECT);
525 static short select_grouped_layer(bContext *C, Object *ob)
529 CTX_DATA_BEGIN(C, Base*, base, selectable_bases) {
530 if ((base->lay & ob->lay) && !(base->flag & SELECT)) {
531 ED_base_object_select(base, BA_SELECT);
539 static short select_grouped_index_object(bContext *C, Object *ob)
543 CTX_DATA_BEGIN(C, Base*, base, selectable_bases) {
544 if ((base->object->index == ob->index) && !(base->flag & SELECT)) {
545 ED_base_object_select(base, BA_SELECT);
553 static short select_grouped_color(bContext *C, Object *ob)
557 CTX_DATA_BEGIN(C, Base*, base, selectable_bases) {
558 if (!(base->flag & SELECT) && (compare_v3v3(base->object->col, ob->col, 0.005f))) {
559 ED_base_object_select(base, BA_SELECT);
567 static short objects_share_gameprop(Object *a, Object *b)
570 /*make a copy of all its properties*/
572 for( prop= a->prop.first; prop; prop = prop->next ) {
573 if ( get_ob_property(b, prop->name) )
579 static short select_grouped_gameprops(bContext *C, Object *ob)
583 CTX_DATA_BEGIN(C, Base*, base, selectable_bases) {
584 if (!(base->flag & SELECT) && (objects_share_gameprop(base->object, ob))) {
585 ED_base_object_select(base, BA_SELECT);
593 static short select_grouped_keyingset(bContext *C, Object *UNUSED(ob))
595 KeyingSet *ks = ANIM_scene_get_active_keyingset(CTX_data_scene(C));
598 /* firstly, validate KeyingSet */
599 if ((ks == NULL) || (ANIM_validate_keyingset(C, NULL, ks) != 0))
602 /* select each object that Keying Set refers to */
603 // TODO: perhaps to be more in line with the rest of these, we should only take objects
604 // if the passed in object is included in this too
605 CTX_DATA_BEGIN(C, Base*, base, selectable_bases)
607 /* only check for this object if it isn't selected already, to limit time wasted */
608 if ((base->flag & SELECT) == 0) {
611 /* this is the slow way... we could end up with > 500 items here,
612 * with none matching, but end up doing this on 1000 objects...
614 for (ksp = ks->paths.first; ksp; ksp = ksp->next) {
615 /* if id matches, select then stop looping (match found) */
616 if (ksp->id == (ID *)base->object) {
617 ED_base_object_select(base, BA_SELECT);
629 static int object_select_grouped_exec(bContext *C, wmOperator *op)
631 Scene *scene= CTX_data_scene(C);
633 int nr = RNA_enum_get(op->ptr, "type");
634 short changed = 0, extend;
636 extend= RNA_boolean_get(op->ptr, "extend");
639 CTX_DATA_BEGIN(C, Base*, base, visible_bases) {
640 ED_base_object_select(base, BA_DESELECT);
648 BKE_report(op->reports, RPT_ERROR, "No Active Object");
649 return OPERATOR_CANCELLED;
652 if(nr==1) changed |= select_grouped_children(C, ob, 1);
653 else if(nr==2) changed |= select_grouped_children(C, ob, 0);
654 else if(nr==3) changed |= select_grouped_parent(C);
655 else if(nr==4) changed |= select_grouped_siblings(C, ob);
656 else if(nr==5) changed |= select_grouped_type(C, ob);
657 else if(nr==6) changed |= select_grouped_layer(C, ob);
658 else if(nr==7) changed |= select_grouped_group(C, ob);
659 else if(nr==8) changed |= select_grouped_object_hooks(C, ob);
660 else if(nr==9) changed |= select_grouped_index_object(C, ob);
661 else if(nr==10) changed |= select_grouped_color(C, ob);
662 else if(nr==11) changed |= select_grouped_gameprops(C, ob);
663 else if(nr==12) changed |= select_grouped_keyingset(C, ob);
666 WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, CTX_data_scene(C));
667 return OPERATOR_FINISHED;
670 return OPERATOR_CANCELLED;
673 void OBJECT_OT_select_grouped(wmOperatorType *ot)
676 ot->name= "Select Grouped";
677 ot->description = "Select all visible objects grouped by various properties";
678 ot->idname= "OBJECT_OT_select_grouped";
681 ot->invoke= WM_menu_invoke;
682 ot->exec= object_select_grouped_exec;
683 ot->poll= objects_selectable_poll;
686 ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
689 RNA_def_boolean(ot->srna, "extend", FALSE, "Extend", "Extend selection instead of deselecting everything first");
690 ot->prop= RNA_def_enum(ot->srna, "type", prop_select_grouped_types, 0, "Type", "");
693 /************************* Select by Layer **********************/
695 static int object_select_by_layer_exec(bContext *C, wmOperator *op)
697 unsigned int layernum;
700 extend= RNA_boolean_get(op->ptr, "extend");
701 layernum = RNA_int_get(op->ptr, "layers");
704 CTX_DATA_BEGIN(C, Base*, base, visible_bases) {
705 ED_base_object_select(base, BA_DESELECT);
710 CTX_DATA_BEGIN(C, Base*, base, visible_bases) {
711 if(base->lay == (1<< (layernum -1)))
712 ED_base_object_select(base, BA_SELECT);
717 WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, CTX_data_scene(C));
719 return OPERATOR_FINISHED;
722 void OBJECT_OT_select_by_layer(wmOperatorType *ot)
725 ot->name= "Select by Layer";
726 ot->description = "Select all visible objects on a layer";
727 ot->idname= "OBJECT_OT_select_by_layer";
730 /*ot->invoke = XXX - need a int grid popup*/
731 ot->exec= object_select_by_layer_exec;
732 ot->poll= objects_selectable_poll;
735 ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
738 RNA_def_boolean(ot->srna, "extend", FALSE, "Extend", "Extend selection instead of deselecting everything first");
739 RNA_def_int(ot->srna, "layers", 1, 1, 20, "Layer", "", 1, 20);
742 /**************************** (De)select All ****************************/
744 static int object_select_all_exec(bContext *C, wmOperator *op)
746 int action = RNA_enum_get(op->ptr, "action");
748 /* passthrough if no objects are visible */
749 if (CTX_DATA_COUNT(C, visible_bases) == 0) return OPERATOR_PASS_THROUGH;
751 if (action == SEL_TOGGLE) {
753 CTX_DATA_BEGIN(C, Base*, base, visible_bases) {
754 if (base->flag & SELECT) {
755 action = SEL_DESELECT;
762 CTX_DATA_BEGIN(C, Base*, base, visible_bases) {
765 ED_base_object_select(base, BA_SELECT);
768 ED_base_object_select(base, BA_DESELECT);
771 if (base->flag & SELECT) {
772 ED_base_object_select(base, BA_DESELECT);
774 ED_base_object_select(base, BA_SELECT);
781 WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, CTX_data_scene(C));
783 return OPERATOR_FINISHED;
786 void OBJECT_OT_select_all(wmOperatorType *ot)
790 ot->name= "Select or Deselect All";
791 ot->description = "Change selection of all visible objects in scene";
792 ot->idname= "OBJECT_OT_select_all";
795 ot->exec= object_select_all_exec;
796 ot->poll= objects_selectable_poll;
799 ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
801 WM_operator_properties_select_all(ot);
804 /**************************** Select In The Same Group ****************************/
806 static int object_select_same_group_exec(bContext *C, wmOperator *op)
809 char group_name[MAX_ID_NAME];
811 /* passthrough if no objects are visible */
812 if (CTX_DATA_COUNT(C, visible_bases) == 0) return OPERATOR_PASS_THROUGH;
814 RNA_string_get(op->ptr, "group", group_name);
816 for (group=CTX_data_main(C)->group.first; group; group=group->id.next) {
817 if (!strcmp(group->id.name, group_name))
822 return OPERATOR_PASS_THROUGH;
824 CTX_DATA_BEGIN(C, Base*, base, visible_bases) {
825 if (!(base->flag & SELECT) && object_in_group(base->object, group))
826 ED_base_object_select(base, BA_SELECT);
830 WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, CTX_data_scene(C));
832 return OPERATOR_FINISHED;
835 void OBJECT_OT_select_same_group(wmOperatorType *ot)
839 ot->name= "Select Same Group";
840 ot->description = "Select object in the same group";
841 ot->idname= "OBJECT_OT_select_same_group";
844 ot->exec= object_select_same_group_exec;
845 ot->poll= objects_selectable_poll;
848 ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
850 RNA_def_string(ot->srna, "group", "", MAX_ID_NAME, "Group", "Name of the group to select");
853 /**************************** Select Mirror ****************************/
854 static int object_select_mirror_exec(bContext *C, wmOperator *op)
856 Scene *scene= CTX_data_scene(C);
859 extend= RNA_boolean_get(op->ptr, "extend");
861 CTX_DATA_BEGIN(C, Base*, primbase, selected_bases) {
862 char tmpname[MAXBONENAME];
864 flip_side_name(tmpname, primbase->object->id.name+2, TRUE);
866 if(strcmp(tmpname, primbase->object->id.name+2)!=0) { /* names differ */
867 Object *ob= (Object *)find_id("OB", tmpname);
869 Base *secbase= object_in_scene(ob, scene);
872 ED_base_object_select(secbase, BA_SELECT);
877 if (extend == 0) ED_base_object_select(primbase, BA_DESELECT);
883 WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, CTX_data_scene(C));
885 return OPERATOR_FINISHED;
888 void OBJECT_OT_select_mirror(wmOperatorType *ot)
892 ot->name= "Select Mirror";
893 ot->description = "Select the Mirror objects of the selected object eg. L.sword -> R.sword";
894 ot->idname= "OBJECT_OT_select_mirror";
897 ot->exec= object_select_mirror_exec;
898 ot->poll= objects_selectable_poll;
901 ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
903 RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Extend selection instead of deselecting everything first");
907 /**************************** Select Random ****************************/
909 static int object_select_random_exec(bContext *C, wmOperator *op)
914 extend= RNA_boolean_get(op->ptr, "extend");
917 CTX_DATA_BEGIN(C, Base*, base, visible_bases) {
918 ED_base_object_select(base, BA_DESELECT);
922 percent = RNA_float_get(op->ptr, "percent")/100.0f;
924 CTX_DATA_BEGIN(C, Base*, base, visible_bases) {
925 if (BLI_frand() < percent) {
926 ED_base_object_select(base, BA_SELECT);
931 WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, CTX_data_scene(C));
933 return OPERATOR_FINISHED;
936 void OBJECT_OT_select_random(wmOperatorType *ot)
939 ot->name= "Select Random";
940 ot->description = "Set select on random visible objects";
941 ot->idname= "OBJECT_OT_select_random";
944 /*ot->invoke= object_select_random_invoke XXX - need a number popup ;*/
945 ot->exec = object_select_random_exec;
946 ot->poll= objects_selectable_poll;
949 ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
952 RNA_def_float_percentage(ot->srna, "percent", 50.f, 0.0f, 100.0f, "Percent", "Percentage of objects to select randomly", 0.f, 100.0f);
953 RNA_def_boolean(ot->srna, "extend", FALSE, "Extend Selection", "Extend selection instead of deselecting everything first");