Math Vis Console - fixed errors with invalid objects in console locals #104958

Closed
Andrej wants to merge 3 commits from Andrej730/blender-addons:math_vis_fix_invalid_objects into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.

3 Commits

Author SHA1 Message Date
c1099e6fde more robust check for invalidated RNA data 2023-11-08 20:06:02 +05:00
bc9dfe1421 math vis console - simpler method to get check if object is ID 2023-11-07 15:10:33 +05:00
30930143ef Math Vis Console - fixed errors with invalid objects in console locals
Noticed an error that sometimes gets in the way - it occurs if some blender object get's invalidated (whether when it's removed or it invalidated after undo).
When addon mets this kind of object in console's `locals()` it stops working.

Way to reproduce:

1. Default blender scene, make sure cube is selected
2. Run the code below in the console.
3. You won't be able to see the matrix visualization in viewport and you'll be able to see the console errors below in the system console.

```
a = C.object
m = Matrix()
bpy.data.objects.remove(C.object)
```

Traceback:
```
Traceback (most recent call last):
  File "\Blender\3.6\scripts\addons\space_view3d_math_vis\draw.py", line 72, in draw_callback_px
    data_matrix, data_quat, data_euler, data_vector, data_vector_array = utils.console_math_data()
  File "\Blender\3.6\scripts\addons\space_view3d_math_vis\utils.py", line 156, in console_math_data
    if isinstance(var, Matrix):
ReferenceError: StructRNA of type Object has been removed

```
2023-10-16 13:23:05 +05:00