Fix issue where "C" to close polyline where not updating measurement dimension.

This commit is contained in:
Bruno Perdigão
2025-03-10 14:04:57 -03:00
parent 7af672712f
commit 19c103c627
2 changed files with 17 additions and 17 deletions
+17 -1
View File
@@ -803,7 +803,23 @@ class PolylineOperator:
tool.Blender.update_viewport()
if event.value == "PRESS" and event.type == "C":
tool.Polyline.close_polyline()
# Get the first point coordinates to close the polyline
polyline_data = bpy.context.scene.BIMPolylineProperties.insertion_polyline
polyline_points = polyline_data[0].polyline_points if polyline_data else []
if len(polyline_points) > 2:
first_point = polyline_points[0]
last_point = polyline_points[-1]
if not (first_point.x == last_point.x and first_point.y == last_point.y and first_point.z == last_point.z):
self.input_ui.set_value("X", first_point.x)
self.input_ui.set_value("Y", first_point.y)
if self.input_ui.get_number_value("Z") is not None:
self.input_ui.set_value("Z", first_point.z)
else:
self.input_ui.set_value("Z", 0)
result = tool.Polyline.insert_polyline_point(self.input_ui, self.tool_state)
if result:
self.report({"WARNING"}, result)
PolylineDecorator.update(event, self.tool_state, self.input_ui, self.snapping_points[0])
tool.Blender.update_viewport()
-16
View File
@@ -568,22 +568,6 @@ class Polyline(bonsai.core.tool.Polyline):
total_length = tool.Polyline.format_input_ui_units(total_length)
polyline_data.total_length = total_length
@classmethod
def close_polyline(cls) -> None:
polyline_data = bpy.context.scene.BIMPolylineProperties.insertion_polyline
polyline_points = polyline_data[0].polyline_points if polyline_data else []
if len(polyline_points) > 2:
first_point = polyline_points[0]
last_point = polyline_points[-1]
if not (first_point.x == last_point.x and first_point.y == last_point.y and first_point.z == last_point.z):
polyline_point = polyline_points.add()
polyline_point.x = first_point.x
polyline_point.y = first_point.y
polyline_point.z = first_point.z
polyline_point.dim = first_point.dim
polyline_point.angle = first_point.angle
polyline_point.position = first_point.position
@classmethod
def clear_polyline(cls) -> None:
bpy.context.scene.BIMPolylineProperties.insertion_polyline.clear()