Draft: gui_utils.py fix error in select function (#19539)
* Draft: gui_utils.py fix error in select function PR #18795 changed the select function to also handle tuples. This PR adds a check to ensure the referenced objects in the tuple still exist before calling `Gui.Selection.addSelection()`.
This commit is contained in:
@@ -696,12 +696,16 @@ def select(objs=None, gui=App.GuiUp):
|
||||
if not obj:
|
||||
continue
|
||||
if isinstance(obj, tuple):
|
||||
Gui.Selection.addSelection(*obj)
|
||||
# Example of tuple (Rectangle in Part):
|
||||
# ("", "Part", "Rectangle.")
|
||||
# See:
|
||||
# utils._modifiers_process_selection()
|
||||
# utils._modifiers_process_subselection()
|
||||
parent = App.ActiveDocument.getObject(obj[1])
|
||||
if parent and parent.getSubObject(obj[2]):
|
||||
Gui.Selection.addSelection(*obj)
|
||||
continue
|
||||
try:
|
||||
if not obj.isAttachedToDocument():
|
||||
continue
|
||||
except:
|
||||
if utils.is_deleted(obj):
|
||||
continue
|
||||
Gui.Selection.addSelection(obj)
|
||||
|
||||
|
||||
@@ -389,6 +389,14 @@ def tolerance():
|
||||
return 10 ** -precision()
|
||||
|
||||
|
||||
def is_deleted(obj):
|
||||
"""Return `True` if obj is deleted."""
|
||||
try:
|
||||
return not obj.isAttachedToDocument()
|
||||
except:
|
||||
return True
|
||||
|
||||
|
||||
def get_real_name(name):
|
||||
"""Strip the trailing numbers from a string to get only the letters.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user