mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-10-01 12:40:07 +00:00
Polyline tool - avoids rounding angle when distance is too big.
This commit is contained in:
@@ -172,23 +172,24 @@ class Polyline(bonsai.core.tool.Polyline):
|
|||||||
angle = tool.Cad.angle_3_vectors(
|
angle = tool.Cad.angle_3_vectors(
|
||||||
second_to_last_point, last_point, mouse_vector, new_angle=None, degrees=True
|
second_to_last_point, last_point, mouse_vector, new_angle=None, degrees=True
|
||||||
)
|
)
|
||||||
|
angle_round_threshold = 1000 # Avoids rounding when distance is too big
|
||||||
|
|
||||||
# Round angle to the nearest 0.05
|
# Round angle to the nearest 0.05
|
||||||
angle = round(angle / 0.05) * 0.05
|
angle = round(angle / 0.05) * 0.05 if distance < angle_round_threshold else angle
|
||||||
|
|
||||||
orientation_angle = tool.Cad.angle_3_vectors(
|
orientation_angle = tool.Cad.angle_3_vectors(
|
||||||
world_second_to_last_point, last_point, mouse_vector, new_angle=None, degrees=True
|
world_second_to_last_point, last_point, mouse_vector, new_angle=None, degrees=True
|
||||||
)
|
)
|
||||||
|
|
||||||
# Round angle to the nearest 0.05
|
# Round angle to the nearest 0.05
|
||||||
orientation_angle = round(orientation_angle / 0.05) * 0.05
|
orientation_angle = round(orientation_angle / 0.05) * 0.05 if distance < angle_round_threshold else angle
|
||||||
|
|
||||||
if distance == 0:
|
if distance == 0:
|
||||||
angle = 0
|
angle = 0
|
||||||
orientation_angle = 0
|
orientation_angle = 0
|
||||||
if input_ui:
|
if input_ui:
|
||||||
if should_round:
|
if should_round:
|
||||||
angle = 5 * round(angle / 5)
|
angle = 5 * round(angle / 5) if distance < angle_round_threshold else angle
|
||||||
factor = tool.Snap.get_increment_snap_value(context)
|
factor = tool.Snap.get_increment_snap_value(context)
|
||||||
distance = factor * round(distance / factor)
|
distance = factor * round(distance / factor)
|
||||||
input_ui.set_value("X", mouse_vector.x)
|
input_ui.set_value("X", mouse_vector.x)
|
||||||
|
|||||||
Reference in New Issue
Block a user