Skip to content

Commit

Permalink
Merge branch 'horizontal_vertical_line_constraints'
Browse files Browse the repository at this point in the history
  • Loading branch information
hlorus committed Apr 8, 2024
2 parents 866bb5b + 3b11452 commit d018d09
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions operators/add_line_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

class View3D_OT_slvs_add_line2d(Operator, Operator2d):
"""Add a line to the active sketch"""

bl_idname = Operators.AddLine2D
bl_label = "Add Solvespace 2D Line"
bl_options = {"REGISTER", "UNDO"}
Expand Down Expand Up @@ -54,6 +54,7 @@ def main(self, context: Context):
self.target.construction = True

# auto vertical/horizontal constraint
self.has_alignment = False
constraints = context.scene.sketcher.constraints
vec_dir = self.target.direction_vec()
if vec_dir.length:
Expand All @@ -62,8 +63,10 @@ def main(self, context: Context):
threshold = 0.1
if angle < threshold or angle > HALF_TURN - threshold:
constraints.add_horizontal(self.target, sketch=self.sketch)
self.has_alignment = True
elif (QUARTER_TURN - threshold) < angle < (QUARTER_TURN + threshold):
constraints.add_vertical(self.target, sketch=self.sketch)
self.has_alignment = True

ignore_hover(self.target)
return True
Expand All @@ -83,7 +86,7 @@ def fini(self, context: Context, succeede: bool):
logger.debug("Add: {}".format(self.target))

if succeede:
if self.has_coincident():
if self.has_coincident() or self.has_alignment:
solve_system(context, sketch=self.sketch)


Expand Down

0 comments on commit d018d09

Please sign in to comment.