mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 01:41:57 +00:00
Added snaping to polyline points
This commit is contained in:
committed by
Bruno Perdigão
parent
4b4e6fa7e2
commit
bc0efd7389
@@ -363,7 +363,6 @@ class WallPolylineDecorator:
|
||||
current_axis = (Vector((last_point.x, last_point.y)), Vector((snap_vector.x, snap_vector.y))) # TODO get height from default container
|
||||
if distance > 0:
|
||||
angle = tool.Cad.angle_edges(x_axis_edge, current_axis, degrees=True, signed=True)
|
||||
print("ANGLE", angle, radians(angle))
|
||||
if cls.input_panel:
|
||||
cls.input_panel['X'] = str(round(snap_vector.x, 4))
|
||||
cls.input_panel['Y'] = str(round(snap_vector.y, 4))
|
||||
@@ -490,15 +489,12 @@ class WallPolylineDecorator:
|
||||
self.draw_batch("LINES", [polyline_points[-1]] + mouse_point, decorator_color_unselected, edges)
|
||||
|
||||
# Line for angle axis snap
|
||||
print("TYPE", snap_prop.snap_type)
|
||||
if snap_prop.snap_type == 'Axis':
|
||||
length = 1000
|
||||
direction = Vector((1, 0, 0))
|
||||
rot_dir = self.angle_snap_mat.inverted() @ direction
|
||||
start = self.angle_snap_loc + rot_dir * length
|
||||
end = self.angle_snap_loc - rot_dir * length
|
||||
print("START", start)
|
||||
print("END", end)
|
||||
self.line_shader.uniform_float("lineWidth", 1.0)
|
||||
self.line_shader.uniform_float("lineWidth", 0.75)
|
||||
self.draw_batch("LINES", [start, end], decorator_color_unselected, [(0,1)])
|
||||
|
||||
|
||||
@@ -485,7 +485,12 @@ class DrawPolylineWall(bpy.types.Operator):
|
||||
tool.Snaping.update_snaping_point(hit, "Face")
|
||||
|
||||
else:
|
||||
if rot_intersection:
|
||||
snap_points = tool.Snaping.get_snap_points_on_polyline()
|
||||
snap_point = tool.Snaping.select_snap_point(snap_points, intersection, snap_threshold)
|
||||
|
||||
if snap_point:
|
||||
tool.Snaping.update_snaping_point(snap_point[0], snap_point[1])
|
||||
elif rot_intersection:
|
||||
tool.Snaping.update_snaping_point(rot_intersection, "Axis")
|
||||
else:
|
||||
tool.Snaping.update_snaping_point(intersection, "Plane")
|
||||
|
||||
@@ -44,6 +44,20 @@ class Snaping(blenderbim.core.tool.Snaping):
|
||||
|
||||
return snap_points
|
||||
|
||||
|
||||
@classmethod
|
||||
def get_snap_points_on_polyline(cls):
|
||||
snap_points = {}
|
||||
polyline_data = bpy.context.scene.BIMModelProperties.polyline_point
|
||||
polyline_points = []
|
||||
for point_data in polyline_data:
|
||||
point = Vector((point_data.x, point_data.y, point_data.z))
|
||||
polyline_points.append(point)
|
||||
snap_points.update({tuple(point): "Polyline Point" for point in polyline_points})
|
||||
|
||||
return snap_points
|
||||
|
||||
|
||||
@classmethod
|
||||
def select_snap_point(cls, snap_points, hit, threshold):
|
||||
shortest_distance = None
|
||||
@@ -116,14 +130,12 @@ class Snaping(blenderbim.core.tool.Snaping):
|
||||
rot_mat = Matrix.Rotation(math.radians(360 - angle), 3, 'Z')
|
||||
WallPolylineDecorator.set_angle_axis_line(rot_mat, last_point)
|
||||
rot_intersection = rot_mat @ translated_intersection
|
||||
print("ROT_INT", rot_intersection)
|
||||
is_on_rot_axis = abs(rot_intersection.y) <= 0.60
|
||||
if is_on_rot_axis:
|
||||
# snap to axis
|
||||
rot_intersection = Vector((rot_intersection.x, 0, rot_intersection.z))
|
||||
# convert it back
|
||||
snap_intersection = rot_mat.inverted() @ rot_intersection + last_point
|
||||
print('SNAP', snap_intersection)
|
||||
return snap_intersection
|
||||
|
||||
return None
|
||||
|
||||
Reference in New Issue
Block a user