@@ -176,7 +176,7 @@ def tool_createGroupsFromNames(scene):
176176 except : pass
177177
178178 # 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 ]
180180 # Find mesh objects in selection
181181 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 ]
182182 if len (objs ) == 0 :
@@ -241,7 +241,7 @@ def tool_applyAllModifiers(scene):
241241 except : pass
242242
243243 # 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 ]
245245 selectionActive = bpy .context .scene .objects .active
246246 # Find mesh objects in selection
247247 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):
352352 except : pass
353353
354354 # 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 ]
356356 selectionActive = bpy .context .scene .objects .active
357357 # Find mesh objects in selection
358358 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):
402402 except : pass
403403
404404 # 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 ]
406406 selectionActive = bpy .context .scene .objects .active
407407
408408 ### Sort out user-defined objects (members of a specific group)
@@ -441,7 +441,7 @@ def tool_separateLoose(scene):
441441 kk_mesh_separate_loose .run ()
442442
443443 # 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 ]
445445
446446 # Deselect objects with modifiers (in case they have not been applied yet)
447447 for obj in selection :
@@ -471,7 +471,7 @@ def tool_remesh(scene):
471471 except : pass
472472
473473 # 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 ]
475475 selectionActive = bpy .context .scene .objects .active
476476
477477 ### Sort out user-defined objects (members of a specific group)
@@ -542,7 +542,7 @@ def tool_discretize(scene):
542542 except : pass
543543
544544 # 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 ]
546546 selectionActive = bpy .context .scene .objects .active
547547
548548 ### Sort out user-defined objects (members of a specific group)
@@ -561,7 +561,10 @@ def tool_discretize(scene):
561561 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 ]
562562 if len (objs ) == 0 :
563563 print ("No mesh objects selected." )
564+ # Revert to start selection
565+ for obj in selectionBak : obj .select = 1
564566 return
567+
565568 # Find empty objects with constraints in selection
566569 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 ]
567570 # Remove mesh objects which are used within constraints (we want to leave them untouched)
@@ -577,8 +580,11 @@ def tool_discretize(scene):
577580 for obj in objs :
578581 if obj not in objsConst : objsNew .append (obj )
579582 objs = objsNew
583+
580584 if len (objs ) == 0 :
581585 print ("No mesh objects changed because of attached constraints." )
586+ # Revert to start selection
587+ for obj in selectionBak : obj .select = 1
582588 return
583589
584590 ### 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):
844850 except : pass
845851
846852 # 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 ]
848854 selectionActive = bpy .context .scene .objects .active
849855 # Find mesh objects in selection
850856 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):
898904 except : pass
899905
900906 # 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 ]
902908 selectionActive = bpy .context .scene .objects .active
903909 # Find mesh objects in selection
904910 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):
977983 except : pass
978984
979985 # 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 ]
981987 selectionActive = bpy .context .scene .objects .active
982988
983989 ### Sort out user-defined objects (members of a specific group)
@@ -996,6 +1002,8 @@ def tool_fixFoundation(scene):
9961002 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 ]
9971003 if len (objs ) == 0 :
9981004 print ("No active rigid body objects selected." )
1005+ # Revert to start selection
1006+ for obj in selectionBak : obj .select = 1
9991007 return
10001008
10011009 props = bpy .context .window_manager .bcb
@@ -1295,7 +1303,7 @@ def tool_groundMotion(scene):
12951303 except : pass
12961304
12971305 # 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 ]
12991307 selectionActive = bpy .context .scene .objects .active
13001308
13011309 ### Sort out user-defined objects (members of a specific group)
@@ -2423,7 +2431,7 @@ def tool_cavityDetection(scene):
24232431 except : pass
24242432
24252433 # 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 ]
24272435 selectionActive = bpy .context .scene .objects .active
24282436 # Find mesh objects in selection
24292437 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