From 3aa61531a8a56a1079d725b850565ec75b93ba18 Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Thu, 1 Jun 2017 19:02:15 -0300 Subject: [PATCH] Draft: Added snapping between mid of two hold points --- src/Mod/Draft/DraftSnap.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Mod/Draft/DraftSnap.py b/src/Mod/Draft/DraftSnap.py index 045e83637f..4b81e6fba3 100644 --- a/src/Mod/Draft/DraftSnap.py +++ b/src/Mod/Draft/DraftSnap.py @@ -33,7 +33,7 @@ __url__ = "http://www.freecadweb.org" # everything that goes with it (toolbar buttons, cursor icons, etc) -import FreeCAD, FreeCADGui, math, Draft, DraftGui, DraftTrackers, DraftVecUtils +import FreeCAD, FreeCADGui, math, Draft, DraftGui, DraftTrackers, DraftVecUtils, itertools from collections import OrderedDict from FreeCAD import Vector from pivy import coin @@ -719,7 +719,14 @@ class Snapper: u = FreeCAD.Vector(1,0,0) v = FreeCAD.Vector(0,1,0) if len(self.holdPoints) > 1: - # first try int points + # first try mid points + if self.isEnabled("midpoint"): + l = list(self.holdPoints) + for p1,p2 in itertools.combinations(l,2): + p3 = p1.add((p2.sub(p1)).multiply(0.5)) + if (p3.sub(point)).Length < self.radius: + return [p1,'midpoint',p3] + # then try int points ipoints = [] l = list(self.holdPoints) while len(l) > 1: