Poyline tool - Adds more layers to increment snap base on viewport zoom.

This commit is contained in:
Bruno Perdigão
2024-10-10 20:13:00 -03:00
parent b4d652d12e
commit cdaa782c18
2 changed files with 22 additions and 11 deletions
-1
View File
@@ -577,7 +577,6 @@ class Polyline(bonsai.core.tool.Polyline):
polyline_point.dim = d
polyline_point.angle = a
polyline_point.position = Vector((x, y, z))
print(polyline_point.x, polyline_point.y, polyline_point.z)
# Add total length
total_length = 0
+22 -10
View File
@@ -46,29 +46,41 @@ class Snap(bonsai.core.tool.Snap):
rv3d = context.region_data
factor = 1
fraction = 10
reference_value = -0.1
distance = 10
fractions = [100, 20, 10, 2]
ortho_threshold = [-0.5, -0.25, -0.15, -0.05]
distances = [3, 5, 15, 30]
unit_system = tool.Drawing.get_unit_system()
if unit_system == "IMPERIAL":
factor = 3.28084
fraction = 12
reference_value = -0.4
distance = 5
fractions = [24, 12, 6, 2]
ortho_threshold = [-10.0, -4.75, -2.2, -0.75]
distances = [3, 6, 10, 20]
increment = None
if rv3d.view_perspective == "PERSP":
if rv3d.view_distance < distance:
increment = (1 / fraction) / factor
if rv3d.view_distance < distances[0]:
increment = (1 / fractions[0]) / factor
elif distances[0] < rv3d.view_distance < distances[1]:
increment = (1 / fractions[1]) / factor
elif distances[1] < rv3d.view_distance < distances[2]:
increment = (1 / fractions[2]) / factor
elif distances[2] < rv3d.view_distance < distances[3]:
increment = (1 / fractions[3]) / factor
else:
increment = 1 / factor
if rv3d.view_perspective == "ORTHO" or (
rv3d.view_perspective == "CAMERA" and context.scene.camera.data.type == "ORTHO"
):
window_scale = rv3d.window_matrix.to_scale()
if window_scale[0] < reference_value and window_scale[1] < reference_value:
increment = (1 / fraction) / factor
if window_scale[1] < ortho_threshold[0]:
increment = (1 / fractions[0]) / factor
elif ortho_threshold[0] < window_scale[1] < ortho_threshold[1]:
increment = (1 / fractions[1]) / factor
elif ortho_threshold[1] < window_scale[1] < ortho_threshold[2]:
increment = (1 / fractions[2]) / factor
elif ortho_threshold[2] < window_scale[1] < ortho_threshold[3]:
increment = (1 / fractions[3]) / factor
else:
increment = 1 / factor