mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-13 02:47:48 +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):
|
def handle_inserting_polyline(self, context, event):
|
||||||
if event.value == "RELEASE" and event.type == "LEFTMOUSE":
|
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()
|
tool.Blender.update_viewport()
|
||||||
|
|
||||||
if event.value == "PRESS" and event.type == "C":
|
if event.value == "PRESS" and event.type == "C":
|
||||||
@@ -265,7 +267,9 @@ class PolylineOperator:
|
|||||||
):
|
):
|
||||||
is_valid = self.recalculate_inputs(context)
|
is_valid = self.recalculate_inputs(context)
|
||||||
if is_valid:
|
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.mode = "Mouse"
|
||||||
self.tool_state.is_input_on = False
|
self.tool_state.is_input_on = False
|
||||||
|
|||||||
@@ -134,12 +134,18 @@ class Snap(bonsai.core.tool.Snap):
|
|||||||
y = snap_vertex.y
|
y = snap_vertex.y
|
||||||
z = snap_vertex.z
|
z = snap_vertex.z
|
||||||
|
|
||||||
# Avoids creating two points at the same location
|
|
||||||
polyline_data = bpy.context.scene.BIMPolylineProperties.polyline_point
|
polyline_data = bpy.context.scene.BIMPolylineProperties.polyline_point
|
||||||
if polyline_data:
|
if polyline_data:
|
||||||
last_point = polyline_data[len(polyline_data) - 1]
|
# Avoids creating two points at the same location
|
||||||
if (x, y, z) == (round(last_point.x, 4), round(last_point.y, 4), round(last_point.z, 4)):
|
for point in polyline_data[1:]: # The first can be repeated to form a wall loop
|
||||||
return
|
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 = bpy.context.scene.BIMPolylineProperties.polyline_point.add()
|
||||||
polyline_point.x = x
|
polyline_point.x = x
|
||||||
|
|||||||
Reference in New Issue
Block a user