Skip to content

Commit

Permalink
[Draft] Edit bugfix: closed wire check for point lying in the face plane
Browse files Browse the repository at this point in the history
  • Loading branch information
carlopav authored and berndhahnebach committed Mar 3, 2020
1 parent b1a71f4 commit 432ae7c
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/Mod/Draft/DraftEdit.py
Expand Up @@ -2,6 +2,7 @@
#***************************************************************************
#* Copyright (c) 2009, 2010 Yorik van Havre <yorik@uncreated.net> *
#* Copyright (c) 2009, 2010 Ken Cline <cline@frii.com> *
#* Copyright (c) 2019, 2020 Carlo Pavan <carlopav@gmail.com> *
#* *
#* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU Lesser General Public License (LGPL) *
Expand Down Expand Up @@ -1118,17 +1119,19 @@ def updateWire(self, obj, nodeIndex, v):
return
if Draft.getType(obj) in ["BezCurve"]:
pts = self.recomputePointsBezier(obj,pts,nodeIndex,v,obj.Degree,moveTrackers=False)
# check that the new point lies on the plane of the wire
import DraftGeomUtils, DraftVecUtils

if obj.Closed:
n = DraftGeomUtils.getNormal(obj.Shape)
dv = editPnt.sub(pts[nodeIndex])
rn = DraftVecUtils.project(dv,n)
if dv.Length:
editPnt = editPnt.add(rn.negative())
# check that the new point lies on the plane of the wire
if hasattr(obj.Shape,"normalAt"):
normal = obj.Shape.normalAt(0,0)
point_on_plane = obj.Shape.Vertexes[0].Point
print(v)
v.projectToPlane(point_on_plane, normal)
print(v)
editPnt = obj.getGlobalPlacement().inverse().multVec(v)
pts[nodeIndex] = editPnt
obj.Points = pts
#self.trackers[obj.Name][nodeIndex].set(v)
self.trackers[obj.Name][nodeIndex].set(v)


def recomputePointsBezier(self,obj,pts,idx,v,degree,moveTrackers=True):
Expand Down

0 comments on commit 432ae7c

Please sign in to comment.