From 5a4ca2a4f7c2bd105c17f3faedfbb931402a30db Mon Sep 17 00:00:00 2001 From: vocx-fc Date: Thu, 8 Aug 2019 00:56:37 -0500 Subject: [PATCH] Draft: WorkingPlane, Pythonic style, improved the docstring; setup() only works when 'FreeCAD.GuiUp' is True, otherwise it fails silently. This should be change to print a message to the console. --- src/Mod/Draft/WorkingPlane.py | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/src/Mod/Draft/WorkingPlane.py b/src/Mod/Draft/WorkingPlane.py index 383af24d19..e6e96ddea9 100644 --- a/src/Mod/Draft/WorkingPlane.py +++ b/src/Mod/Draft/WorkingPlane.py @@ -633,7 +633,36 @@ class plane: return False def setup(self, direction=None, point=None, upvec=None): - '''If working plane is undefined, define it!''' + """Setup the working plane if it exists but is undefined. + + If `direction` and `point` are present, + it calls `alignToPointAndAxis(point, direction, 0, upvec)`. + + Otherwise, it gets the camera orientation to define + a working plane that is perpendicular to the current view, + centered at the origin, and with `v` pointing up on the screen. + + This method only works when the `weak` attribute is `True`. + This method also sets `weak` to `True`. + + This method only works when `FreeCAD.GuiUp` is `True`, + that is, when the graphical interface is loaded. + Otherwise it fails silently. + + Parameters + ---------- + direction : Base::Vector3, optional + It defaults to `None`. It is the new `axis` of the plane. + point : Base::Vector3, optional + It defaults to `None`. It is the new `position` of the plane. + upvec : Base::Vector3, optional + It defaults to `None`. It is the new `v` orientation of the plane. + + To do + ----- + It should fail loudly, with a message at least + `FreeCAD.Console.PrintError()`. + """ if self.weak: if direction and point: self.alignToPointAndAxis(point, direction, 0, upvec)