mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-10-03 21:38:12 +00:00
Fix snap system (#5782) by changing the priorities.
The priority now follows this order: 1. Polyline 2. Measure 3. Faceless objects 4. Objects 5. Axis 6. Viewport plane
This commit is contained in:
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
import bmesh
|
import bmesh
|
||||||
import bpy
|
import bpy
|
||||||
|
import copy
|
||||||
from bpy_extras import view3d_utils
|
from bpy_extras import view3d_utils
|
||||||
import bonsai.core.tool
|
import bonsai.core.tool
|
||||||
import bonsai.tool as tool
|
import bonsai.tool as tool
|
||||||
@@ -194,7 +195,8 @@ class Raycast(bonsai.core.tool.Raycast):
|
|||||||
snapping_points = []
|
snapping_points = []
|
||||||
sorted_points = sorted(points)
|
sorted_points = sorted(points)
|
||||||
for p in sorted_points:
|
for p in sorted_points:
|
||||||
snapping_points.append(p[1])
|
point = copy.deepcopy(p)
|
||||||
|
snapping_points.append(point[1])
|
||||||
|
|
||||||
return snapping_points
|
return snapping_points
|
||||||
|
|
||||||
|
|||||||
@@ -362,23 +362,6 @@ class Snap(bonsai.core.tool.Snap):
|
|||||||
): # Check for local view and local collections for this viewport and object
|
): # Check for local view and local collections for this viewport and object
|
||||||
objs_to_raycast.append(obj)
|
objs_to_raycast.append(obj)
|
||||||
|
|
||||||
# Obj
|
|
||||||
snap_obj, hit, face_index = cast_rays_and_get_best_object(objs_to_raycast, mouse_pos)
|
|
||||||
if hit is not None:
|
|
||||||
detected_snaps.append({"Object": (snap_obj, hit, face_index)})
|
|
||||||
|
|
||||||
# Edge-Vertex
|
|
||||||
for obj in objs_to_raycast:
|
|
||||||
if obj.type == "MESH":
|
|
||||||
if len(obj.data.polygons) == 0:
|
|
||||||
options = tool.Raycast.ray_cast_by_proximity(context, event, obj)
|
|
||||||
snap_obj = obj
|
|
||||||
if options:
|
|
||||||
detected_snaps.append({"Edge-Vertex": (snap_obj, options)})
|
|
||||||
break
|
|
||||||
if obj.type == "EMPTY":
|
|
||||||
snap_point = [(obj.location, "Vertex")]
|
|
||||||
detected_snaps.append({"Edge-Vertex": (obj, snap_point)})
|
|
||||||
# Polyline
|
# Polyline
|
||||||
try:
|
try:
|
||||||
polyline_data = bpy.context.scene.BIMPolylineProperties.insertion_polyline[0]
|
polyline_data = bpy.context.scene.BIMPolylineProperties.insertion_polyline[0]
|
||||||
@@ -400,6 +383,24 @@ class Snap(bonsai.core.tool.Snap):
|
|||||||
if snap_points:
|
if snap_points:
|
||||||
detected_snaps.append({"Polyline": snap_points})
|
detected_snaps.append({"Polyline": snap_points})
|
||||||
|
|
||||||
|
# Edge-Vertex
|
||||||
|
for obj in objs_to_raycast:
|
||||||
|
if obj.type == "MESH":
|
||||||
|
if len(obj.data.polygons) == 0:
|
||||||
|
options = tool.Raycast.ray_cast_by_proximity(context, event, obj)
|
||||||
|
snap_obj = obj
|
||||||
|
if options:
|
||||||
|
detected_snaps.append({"Edge-Vertex": (snap_obj, options)})
|
||||||
|
break
|
||||||
|
if obj.type == "EMPTY":
|
||||||
|
snap_point = [(obj.location, "Vertex")]
|
||||||
|
detected_snaps.append({"Edge-Vertex": (obj, snap_point)})
|
||||||
|
|
||||||
|
# Obj
|
||||||
|
snap_obj, hit, face_index = cast_rays_and_get_best_object(objs_to_raycast, mouse_pos)
|
||||||
|
if hit is not None:
|
||||||
|
detected_snaps.append({"Object": (snap_obj, hit, face_index)})
|
||||||
|
|
||||||
# Axis and Plane
|
# Axis and Plane
|
||||||
elevation = tool.Ifc.get_object(tool.Root.get_default_container()).location.z
|
elevation = tool.Ifc.get_object(tool.Root.get_default_container()).location.z
|
||||||
|
|
||||||
@@ -453,6 +454,22 @@ class Snap(bonsai.core.tool.Snap):
|
|||||||
snapping_points = []
|
snapping_points = []
|
||||||
for origin in detected_snaps:
|
for origin in detected_snaps:
|
||||||
snap_obj = None
|
snap_obj = None
|
||||||
|
if "Polyline" in origin:
|
||||||
|
options = origin["Polyline"]
|
||||||
|
for op in options:
|
||||||
|
snapping_points.append(op + (snap_obj,))
|
||||||
|
break
|
||||||
|
if "Measure" in origin:
|
||||||
|
options = origin["Measure"]
|
||||||
|
for op in options:
|
||||||
|
snapping_points.append(op + (snap_obj,))
|
||||||
|
break
|
||||||
|
if "Edge-Vertex" in origin:
|
||||||
|
snap_obj, options = origin["Edge-Vertex"]
|
||||||
|
print(">>>", snap_obj, options)
|
||||||
|
for op in options:
|
||||||
|
snapping_points.append(op + (snap_obj,))
|
||||||
|
break
|
||||||
if "Object" in origin:
|
if "Object" in origin:
|
||||||
snap_obj, hit, face_index = origin["Object"]
|
snap_obj, hit, face_index = origin["Object"]
|
||||||
matrix = snap_obj.matrix_world.copy()
|
matrix = snap_obj.matrix_world.copy()
|
||||||
@@ -467,19 +484,6 @@ class Snap(bonsai.core.tool.Snap):
|
|||||||
else:
|
else:
|
||||||
for op in options:
|
for op in options:
|
||||||
snapping_points.append(op + (snap_obj,))
|
snapping_points.append(op + (snap_obj,))
|
||||||
|
|
||||||
break
|
|
||||||
|
|
||||||
if "Edge-Vertex" in origin:
|
|
||||||
snap_obj, options = origin["Edge-Vertex"]
|
|
||||||
for op in options:
|
|
||||||
snapping_points.append(op + (snap_obj,))
|
|
||||||
break
|
|
||||||
|
|
||||||
if "Polyline" in origin:
|
|
||||||
options = origin["Polyline"]
|
|
||||||
for op in options:
|
|
||||||
snapping_points.append(op + (snap_obj,))
|
|
||||||
break
|
break
|
||||||
|
|
||||||
for origin in detected_snaps:
|
for origin in detected_snaps:
|
||||||
|
|||||||
Reference in New Issue
Block a user