Skip to content

Commit 8f2a3a4

Browse files
Draft : Added knots support for snapping (FreeCAD#26571)
* Draft : Added knots support for snapping Signed-off-by: Yash Suthar <yashsuthar983@gmail.com> * Use Special snap for knots and rename snapToBSpline to snapToBSplineKnots --------- Signed-off-by: Yash Suthar <yashsuthar983@gmail.com> Co-authored-by: Roy-043 <70520633+Roy-043@users.noreply.github.com>
1 parent 21a597a commit 8f2a3a4

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/Mod/Draft/draftguitools/gui_snapper.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,8 @@ def snapToObject(self, lastpoint, active, constrain, eline, point):
413413
elif et == "Ellipse":
414414
# extra ellipse options
415415
snaps.extend(self.snapToCenter(edge))
416+
elif et == "BSplineCurve":
417+
snaps.extend(self.snapToBSplineKnots(edge))
416418
elif "Face" in comp:
417419
# we are snapping to a face
418420
if shape.ShapeType == "Face":
@@ -800,6 +802,17 @@ def snapToMidpoint(self, shape):
800802
snaps.append([mp, "midpoint", self.toWP(mp)])
801803
return snaps
802804

805+
def snapToBSplineKnots(self, edge):
806+
"""Return a list of knot snap locations for a BSpline."""
807+
snaps = []
808+
if self.isEnabled("Special"):
809+
if hasattr(edge, "Curve") and isinstance(edge.Curve, Part.BSplineCurve):
810+
knots = edge.Curve.getKnots()
811+
for k in knots:
812+
p = edge.Curve.value(k)
813+
snaps.append([p, "special", self.toWP(p)])
814+
return snaps
815+
803816
def snapToNear(self, shape, point):
804817
"""Return a list with a near snap location for an edge."""
805818
if self.isEnabled("Near") and point:

0 commit comments

Comments
 (0)