Draft: move make_dimension function to its own module
Previously the `make_dimension` and `make_angular_dimension` functions were in `draftobjects/dimension.py`. Now they are moved to `draftmake/make_dimension.py`. The original `makeAngularDimension` function requires angles in radians which is counterintuitive for most cases. Also the order is `[big, small]`. The new function `make_angular_dimension` accepts angles in degrees, and the order is `[small, big]`. The older function is retained for compatibility purposes. Also perform several improvements such as PEP8 cleanup, writing complete docstrings, type checking the input arguments, and depreacting the older call. The `Draft.py` module, Gui Command, unit test, and test script are updated accordingly.
This commit is contained in:
@@ -39,7 +39,6 @@ Or load it as a module and use the defined function.
|
||||
# @{
|
||||
|
||||
import datetime
|
||||
import math
|
||||
import os
|
||||
|
||||
import FreeCAD as App
|
||||
@@ -260,8 +259,8 @@ def _create_objects(doc=None,
|
||||
_msg("Angular dimension")
|
||||
Draft.make_line(Vector(10500, 300, 0), Vector(11500, 1000, 0))
|
||||
Draft.make_line(Vector(10500, 300, 0), Vector(11500, 0, 0))
|
||||
angle1 = math.radians(40)
|
||||
angle2 = math.radians(-20)
|
||||
angle1 = -20
|
||||
angle2 = 40
|
||||
dimension_a = Draft.make_angular_dimension(Vector(10500, 300, 0),
|
||||
[angle1, angle2],
|
||||
Vector(11500, 300, 0))
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
"""Unit test for the Draft Workbench, object creation tests."""
|
||||
|
||||
import unittest
|
||||
import math
|
||||
|
||||
import FreeCAD as App
|
||||
import Draft
|
||||
@@ -210,14 +209,13 @@ class DraftCreation(unittest.TestCase):
|
||||
_msg(" Test '{}'".format(operation))
|
||||
_msg(" Occasionally crashes")
|
||||
center = Vector(0, 0, 0)
|
||||
angle1 = math.radians(60)
|
||||
angle2 = math.radians(10)
|
||||
p3 = Vector(3, 1, 0)
|
||||
angle1 = 20
|
||||
angle2 = 70
|
||||
dim_line = Vector(3, 1, 0)
|
||||
_msg(" center={}".format(center))
|
||||
_msg(" angle1={0}, angle2={1}".format(math.degrees(angle1),
|
||||
math.degrees(angle2)))
|
||||
_msg(" point={}".format(p3))
|
||||
obj = Draft.make_angular_dimension(center, [angle1, angle2], p3)
|
||||
_msg(" angle1={0}, angle2={1}".format(angle1, angle2))
|
||||
_msg(" dim_line={}".format(dim_line))
|
||||
obj = Draft.make_angular_dimension(center, [angle1, angle2], dim_line)
|
||||
self.assertTrue(obj, "'{}' failed".format(operation))
|
||||
|
||||
def test_bspline(self):
|
||||
|
||||
Reference in New Issue
Block a user