mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 09:48:32 +00:00
Warning messages for prohibit cases when inserting polyline points
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user