Skip to content

Commit

Permalink
Draft: WorkingPlane, Pythonic style, improved the docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
vocx-fc authored and yorikvanhavre committed Aug 9, 2019
1 parent 53ef53e commit 34c2dcb
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions src/Mod/Draft/WorkingPlane.py
Expand Up @@ -769,14 +769,33 @@ def getNormal(self):
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()
Expand Down

0 comments on commit 34c2dcb

Please sign in to comment.