From 8284ed0cdb49fc9c9757bea72718178a817b397c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Perdig=C3=A3o?= Date: Sat, 3 Aug 2024 09:26:50 -0300 Subject: [PATCH] Fix to allow calculations to work when no point was added yet --- .../blenderbim/bim/module/model/decorator.py | 10 +++++++--- src/blenderbim/blenderbim/bim/module/model/wall.py | 4 ++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/blenderbim/blenderbim/bim/module/model/decorator.py b/src/blenderbim/blenderbim/bim/module/model/decorator.py index 6dfff9d0e6..a83c34af21 100644 --- a/src/blenderbim/blenderbim/bim/module/model/decorator.py +++ b/src/blenderbim/blenderbim/bim/module/model/decorator.py @@ -335,12 +335,16 @@ class WallPolylineDecorator: def calculate_distance_and_angle(cls, context, is_input_on): try: polyline_data = context.scene.BIMModelProperties.polyline_point - snap_prop = context.scene.BIMModelProperties.snap_mouse_point[0] last_point_data = polyline_data[len(polyline_data) - 1] except: - return + last_point_data = None - last_point = Vector((last_point_data.x, last_point_data.y, last_point_data.z)) + snap_prop = context.scene.BIMModelProperties.snap_mouse_point[0] + + if last_point_data: + last_point = Vector((last_point_data.x, last_point_data.y, last_point_data.z)) + else: + last_point = Vector((0, 0, 0,)) if is_input_on: snap_vector = Vector((float(cls.input_panel['X']), float(cls.input_panel['Y']), 0)) diff --git a/src/blenderbim/blenderbim/bim/module/model/wall.py b/src/blenderbim/blenderbim/bim/module/model/wall.py index 9d1ae66dac..431ab4cf2f 100644 --- a/src/blenderbim/blenderbim/bim/module/model/wall.py +++ b/src/blenderbim/blenderbim/bim/module/model/wall.py @@ -540,8 +540,6 @@ class DrawPolylineWall(bpy.types.Operator): if event.type == 'MOUSEMOVE': self.mousemove_count += 1 tool.Blender.update_viewport() - WallPolylineDecorator.set_mouse_position(context, event) - self.input_panel = WallPolylineDecorator.calculate_distance_and_angle(context, self.is_input_on) self.is_input_on = False else: self.mousemove_count = 0 @@ -553,6 +551,8 @@ class DrawPolylineWall(bpy.types.Operator): if self.mousemove_count > 3: self.snaping_movement(context, event) + WallPolylineDecorator.set_mouse_position(context, event) + self.input_panel = WallPolylineDecorator.calculate_distance_and_angle(context, self.is_input_on) return {'RUNNING_MODAL'} if event.value == 'RELEASE' and event.type == 'LEFTMOUSE':