From 00b174c346b3e4286cb46aabd0e50fc15674f342 Mon Sep 17 00:00:00 2001 From: DeepSOIC Date: Mon, 22 Aug 2016 13:17:06 +0300 Subject: [PATCH] SubLink: Fix #8 : incorrect position of Vertex --- CompoundFilter2.py | 6 ++++-- lattice2ShapeCopy.py | 9 +++++++-- lattice2SubLink.py | 3 ++- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/CompoundFilter2.py b/CompoundFilter2.py index 2d1e762..6459d47 100644 --- a/CompoundFilter2.py +++ b/CompoundFilter2.py @@ -23,6 +23,8 @@ from lattice2Common import * import lattice2Markers as markers +import lattice2ShapeCopy as ShapeCopy + import math import FreeCAD as App @@ -165,8 +167,8 @@ class _CompoundFilter: obj.Shape = Part.makeCompound(rst) else: # don't make compound of one shape, output it directly sh = rst[0] - sh.transformShape(sh.Placement.toMatrix(),True) #True = make copy - sh.Placement = App.Placement() + sh = ShapeCopy.transformCopy(sh) + sh.Placement = obj.Placement obj.Shape = sh return diff --git a/lattice2ShapeCopy.py b/lattice2ShapeCopy.py index 253325c..1d84f6f 100644 --- a/lattice2ShapeCopy.py +++ b/lattice2ShapeCopy.py @@ -27,6 +27,7 @@ __url__ = "" __doc__ = "Utility methods to copy shapes" import FreeCAD +import Part def shallowCopy(shape, extra_placement = None): """shallowCopy(shape, extra_placement = None): creates a shallow copy of a shape. The @@ -67,8 +68,12 @@ def transformCopy(shape, extra_placement = None): if extra_placement is None: extra_placement = FreeCAD.Placement() ret = shape.copy() - ret.transformShape(extra_placement.multiply(ret.Placement).toMatrix(), True) - ret.Placement = FreeCAD.Placement() #reset placement + if ret.ShapeType == "Vertex": + # oddly, on Vertex, transformShape behaves strangely. So we'll create a new vertex instead. + ret = Part.Vertex(extra_placement.multVec(ret.Point)) + else: + ret.transformShape(extra_placement.multiply(ret.Placement).toMatrix(), True) + ret.Placement = FreeCAD.Placement() #reset placement return ret diff --git a/lattice2SubLink.py b/lattice2SubLink.py index 2f15813..f0d312b 100644 --- a/lattice2SubLink.py +++ b/lattice2SubLink.py @@ -29,6 +29,7 @@ from lattice2Common import * from lattice2BaseFeature import isObjectLattice import lattice2Markers as markers import FreeCAD as App +import lattice2ShapeCopy as ShapeCopy # -------------------------- feature -------------------------------------------------- @@ -92,7 +93,7 @@ class LatticeSubLink: else: # don't make compound of one shape, output it directly sh = rst[0] # absorb placement of original shape - sh.transformShape(sh.Placement.toMatrix(),True) #True = make copy + sh = ShapeCopy.transformCopy(sh) # apply Placement that is filled into feature's Placement property (not necessary) sh.Placement = selfobj.Placement selfobj.Shape = sh