Compare commits

..

1 Commits

Author SHA1 Message Date
Ryan Schultz a136ca2d0d Fix #7878: Fix snapping crash with non-mesh objects
Two bugs introduced in 31b571322:
- SnapObj assumed obj.data is always a Mesh; non-mesh
  objects (empties, lights, etc.) have obj.data = None,
  causing an AttributeError on obj.data.edges.
- view3d_utils was used but never imported.

Generated with the assistance of an AI coding tool.
2026-03-31 20:30:56 -05:00
2 changed files with 7 additions and 10 deletions
+1 -8
View File
@@ -18,7 +18,6 @@
from __future__ import annotations
import gc
import hashlib
import os
import shutil
@@ -171,13 +170,7 @@ class IfcStore:
# No point to trying again the same operation.
return
# Force GC to release any dangling HDF5 C-level file handle (Windows).
gc.collect()
try:
os.remove(IfcStore.cache_path)
except PermissionError as e:
print(f"Could not delete locked cache file '{cache_path.name}': {str(e)}. Skipping cache.")
return
os.remove(IfcStore.cache_path)
try:
IfcStore.cache = ifcopenshell.geom.serializers.hdf5(
IfcStore.cache_path, cache_settings, serializer_settings
+6 -2
View File
@@ -25,9 +25,10 @@ import bmesh
import bpy
import mathutils
import numpy as np
from bpy_extras import view3d_utils
from mathutils import Vector
from bpy_extras import view3d_utils
import bonsai.core.tool
import bonsai.tool as tool
@@ -732,7 +733,8 @@ class Raycast(bonsai.core.tool.Raycast):
if tool.Raycast.intersect_mouse_2d_bounding_box(mouse_pos, bbox_2d):
if tool.Raycast.object_is_visible_in_clipping_plane(obj):
snap_obj = cls.create_snap_obj(obj)
objs_to_raycast.append(snap_obj)
if snap_obj is not None:
objs_to_raycast.append(snap_obj)
return objs_to_raycast
@@ -895,6 +897,8 @@ class Raycast(bonsai.core.tool.Raycast):
@classmethod
def create_snap_obj(cls, obj):
if obj.data is None or not isinstance(obj.data, bpy.types.Mesh):
return None
for snap_obj in cls.snap_objs:
if obj.name == snap_obj.obj.name:
return snap_obj