From 34c2dcb2779b1b9259727a0bfd04e0c255b66020 Mon Sep 17 00:00:00 2001 From: vocx-fc Date: Thu, 8 Aug 2019 16:16:47 -0500 Subject: [PATCH] Draft: WorkingPlane, Pythonic style, improved the docstring --- src/Mod/Draft/WorkingPlane.py | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/Mod/Draft/WorkingPlane.py b/src/Mod/Draft/WorkingPlane.py index 72f2540900..10f2a0fdcd 100644 --- a/src/Mod/Draft/WorkingPlane.py +++ b/src/Mod/Draft/WorkingPlane.py @@ -769,14 +769,33 @@ class plane: return n def setFromPlacement(self, pl, rebase=False): - "sets the working plane from a placement (rotaton ONLY, unless rebase=True)" + """Set the plane from a placement. + + It normally uses only the rotation, unless `rebase` is `True`. + + Parameters + ---------- + pl : Base::Placement or Base::Matrix4D + A placement, comprised of a `Base` (`Base::Vector3`), + and a `Rotation` (`Base::Rotation`), + or a `Base::Matrix4D` that defines a placement. + rebase : bool, optional + It defaults to `False`. + If `True`, it will use `pl.Base` as the new `position` + of the plane. Otherwise it will only consider `pl.Rotation`. + + To do + ----- + If `pl` is a `Base::Matrix4D`, it shouldn't try to use `pl.Base` + because a matrix has no `Base`. + """ rot = FreeCAD.Placement(pl).Rotation self.u = rot.multVec(FreeCAD.Vector(1, 0, 0)) self.v = rot.multVec(FreeCAD.Vector(0, 1, 0)) self.axis = rot.multVec(FreeCAD.Vector(0, 0, 1)) if rebase: self.position = pl.Base - + def inverse(self): "inverts the direction of the working plane" self.u = self.u.negative()