@@ -176,7 +176,7 @@ def tool_createGroupsFromNames(scene):
176
176
except : pass
177
177
178
178
# Backup selection
179
- selection = [obj for obj in bpy .context .scene .objects if obj .select ]
179
+ selection = selectionBak = [obj for obj in bpy .context .scene .objects if obj .select ]
180
180
# Find mesh objects in selection
181
181
objs = [obj for obj in selection if obj .type == 'MESH' and not obj .hide and obj .is_visible (bpy .context .scene ) and len (obj .data .vertices ) > 0 ]
182
182
if len (objs ) == 0 :
@@ -241,7 +241,7 @@ def tool_applyAllModifiers(scene):
241
241
except : pass
242
242
243
243
# Backup selection
244
- selection = [obj for obj in bpy .context .scene .objects if obj .select ]
244
+ selection = selectionBak = [obj for obj in bpy .context .scene .objects if obj .select ]
245
245
selectionActive = bpy .context .scene .objects .active
246
246
# Find mesh objects in selection
247
247
objs = [obj for obj in selection if (obj .type == 'MESH' or obj .type == 'CURVE' ) and not obj .hide and obj .is_visible (bpy .context .scene )]
@@ -352,7 +352,7 @@ def tool_centerModel(scene):
352
352
except : pass
353
353
354
354
# Backup selection
355
- selection = [obj for obj in bpy .context .scene .objects if obj .select ]
355
+ selection = selectionBak = [obj for obj in bpy .context .scene .objects if obj .select ]
356
356
selectionActive = bpy .context .scene .objects .active
357
357
# Find mesh objects in selection
358
358
objs = [obj for obj in selection if obj .type == 'MESH' and not obj .hide and obj .is_visible (bpy .context .scene ) and len (obj .data .vertices ) > 0 ]
@@ -402,7 +402,7 @@ def tool_separateLoose(scene):
402
402
except : pass
403
403
404
404
# Backup selection
405
- selection = [obj for obj in bpy .context .scene .objects if obj .select ]
405
+ selection = selectionBak = [obj for obj in bpy .context .scene .objects if obj .select ]
406
406
selectionActive = bpy .context .scene .objects .active
407
407
408
408
### Sort out user-defined objects (members of a specific group)
@@ -441,7 +441,7 @@ def tool_separateLoose(scene):
441
441
kk_mesh_separate_loose .run ()
442
442
443
443
# Update selection list
444
- selection = [obj for obj in bpy .context .scene .objects if obj .select ]
444
+ selection = selectionBak = [obj for obj in bpy .context .scene .objects if obj .select ]
445
445
446
446
# Deselect objects with modifiers (in case they have not been applied yet)
447
447
for obj in selection :
@@ -471,7 +471,7 @@ def tool_remesh(scene):
471
471
except : pass
472
472
473
473
# Backup selection
474
- selection = [obj for obj in bpy .context .scene .objects if obj .select ]
474
+ selection = selectionBak = [obj for obj in bpy .context .scene .objects if obj .select ]
475
475
selectionActive = bpy .context .scene .objects .active
476
476
477
477
### Sort out user-defined objects (members of a specific group)
@@ -542,7 +542,7 @@ def tool_discretize(scene):
542
542
except : pass
543
543
544
544
# Backup selection
545
- selection = [obj for obj in bpy .context .scene .objects if obj .select ]
545
+ selection = selectionBak = [obj for obj in bpy .context .scene .objects if obj .select ]
546
546
selectionActive = bpy .context .scene .objects .active
547
547
548
548
### Sort out user-defined objects (members of a specific group)
@@ -561,7 +561,10 @@ def tool_discretize(scene):
561
561
objs = [obj for obj in selection if obj .type == 'MESH' and not obj .hide and obj .is_visible (bpy .context .scene ) and len (obj .data .vertices ) > 0 ]
562
562
if len (objs ) == 0 :
563
563
print ("No mesh objects selected." )
564
+ # Revert to start selection
565
+ for obj in selectionBak : obj .select = 1
564
566
return
567
+
565
568
# Find empty objects with constraints in selection
566
569
emptyObjs = [obj for obj in selection if obj .type == 'EMPTY' and not obj .hide and obj .is_visible (bpy .context .scene ) and obj .rigid_body_constraint != None ]
567
570
# Remove mesh objects which are used within constraints (we want to leave them untouched)
@@ -577,8 +580,11 @@ def tool_discretize(scene):
577
580
for obj in objs :
578
581
if obj not in objsConst : objsNew .append (obj )
579
582
objs = objsNew
583
+
580
584
if len (objs ) == 0 :
581
585
print ("No mesh objects changed because of attached constraints." )
586
+ # Revert to start selection
587
+ for obj in selectionBak : obj .select = 1
582
588
return
583
589
584
590
### Flip face normals for objects with negative scaling to avoid problems with booleans (will be reverted again when scaling is applied)
@@ -844,7 +850,7 @@ def tool_removeIntersections(scene, mode=1):
844
850
except : pass
845
851
846
852
# Backup selection
847
- selection = [obj for obj in bpy .context .scene .objects if obj .select ]
853
+ selection = selectionBak = [obj for obj in bpy .context .scene .objects if obj .select ]
848
854
selectionActive = bpy .context .scene .objects .active
849
855
# Find mesh objects in selection
850
856
objs = [obj for obj in selection if obj .type == 'MESH' and not obj .hide and obj .is_visible (bpy .context .scene ) and len (obj .data .vertices ) > 0 ]
@@ -898,7 +904,7 @@ def tool_enableRigidBodies(scene):
898
904
except : pass
899
905
900
906
# Backup selection
901
- selection = [obj for obj in bpy .context .scene .objects if obj .select ]
907
+ selection = selectionBak = [obj for obj in bpy .context .scene .objects if obj .select ]
902
908
selectionActive = bpy .context .scene .objects .active
903
909
# Find mesh objects in selection
904
910
objs = [obj for obj in selection if obj .type == 'MESH' and not obj .hide and obj .is_visible (bpy .context .scene ) and len (obj .data .vertices ) > 0 ]
@@ -977,7 +983,7 @@ def tool_fixFoundation(scene):
977
983
except : pass
978
984
979
985
# Backup selection
980
- selection = [obj for obj in bpy .context .scene .objects if obj .select ]
986
+ selection = selectionBak = [obj for obj in bpy .context .scene .objects if obj .select ]
981
987
selectionActive = bpy .context .scene .objects .active
982
988
983
989
### Sort out user-defined objects (members of a specific group)
@@ -996,6 +1002,8 @@ def tool_fixFoundation(scene):
996
1002
objs = [obj for obj in selection if obj .type == 'MESH' and not obj .hide and obj .is_visible (bpy .context .scene ) and obj .rigid_body != None and obj .rigid_body .type == 'ACTIVE' and len (obj .data .vertices ) > 0 ]
997
1003
if len (objs ) == 0 :
998
1004
print ("No active rigid body objects selected." )
1005
+ # Revert to start selection
1006
+ for obj in selectionBak : obj .select = 1
999
1007
return
1000
1008
1001
1009
props = bpy .context .window_manager .bcb
@@ -1295,7 +1303,7 @@ def tool_groundMotion(scene):
1295
1303
except : pass
1296
1304
1297
1305
# Backup selection
1298
- selection = [obj for obj in bpy .context .scene .objects if obj .select ]
1306
+ selection = selectionBak = [obj for obj in bpy .context .scene .objects if obj .select ]
1299
1307
selectionActive = bpy .context .scene .objects .active
1300
1308
1301
1309
### Sort out user-defined objects (members of a specific group)
@@ -2423,7 +2431,7 @@ def tool_cavityDetection(scene):
2423
2431
except : pass
2424
2432
2425
2433
# Backup selection
2426
- selection = [obj for obj in bpy .context .scene .objects if obj .select ]
2434
+ selection = selectionBak = [obj for obj in bpy .context .scene .objects if obj .select ]
2427
2435
selectionActive = bpy .context .scene .objects .active
2428
2436
# Find mesh objects in selection
2429
2437
objs = [obj for obj in selection if obj .type == 'MESH' and not obj .hide and obj .is_visible (bpy .context .scene ) and len (obj .data .vertices ) > 0 ]
0 commit comments