diff --git a/src/bonsai/bonsai/bim/module/model/polyline.py b/src/bonsai/bonsai/bim/module/model/polyline.py index 28092ba719..982ffe1fd7 100644 --- a/src/bonsai/bonsai/bim/module/model/polyline.py +++ b/src/bonsai/bonsai/bim/module/model/polyline.py @@ -250,7 +250,9 @@ class PolylineOperator: def handle_inserting_polyline(self, context, event): if event.value == "RELEASE" and event.type == "LEFTMOUSE": - tool.Snap.insert_polyline_point(self.input_ui) + result = tool.Snap.insert_polyline_point(self.input_ui) + if result: + self.report({'WARNING'}, result) tool.Blender.update_viewport() if event.value == "PRESS" and event.type == "C": @@ -265,7 +267,9 @@ class PolylineOperator: ): is_valid = self.recalculate_inputs(context) if is_valid: - tool.Snap.insert_polyline_point(self.input_ui) + result = tool.Snap.insert_polyline_point(self.input_ui) + if result: + self.report({'WARNING'}, result) self.tool_state.mode = "Mouse" self.tool_state.is_input_on = False diff --git a/src/bonsai/bonsai/tool/snap.py b/src/bonsai/bonsai/tool/snap.py index abb38ae1b8..a5f1e24908 100644 --- a/src/bonsai/bonsai/tool/snap.py +++ b/src/bonsai/bonsai/tool/snap.py @@ -134,12 +134,18 @@ class Snap(bonsai.core.tool.Snap): y = snap_vertex.y z = snap_vertex.z - # Avoids creating two points at the same location polyline_data = bpy.context.scene.BIMPolylineProperties.polyline_point if polyline_data: - last_point = polyline_data[len(polyline_data) - 1] - if (x, y, z) == (round(last_point.x, 4), round(last_point.y, 4), round(last_point.z, 4)): - return + # Avoids creating two points at the same location + for point in polyline_data[1:]: # The first can be repeated to form a wall loop + if (x, y, z) == (point.x, point.y, point.z): + return "Cannot create two points at the same location" + print(type(snap_vertex)) + print(type(polyline_data[-1])) + # Avoids creating segments smaller then 0.1. This is a limitation from create_wall_from_2_points + length = (Vector((x, y, z)) - Vector((polyline_data[-1].x, polyline_data[-1].y, polyline_data[-1].z))).length + if length < 0.1: + return "Cannot create a segment smaller then 10cm" polyline_point = bpy.context.scene.BIMPolylineProperties.polyline_point.add() polyline_point.x = x