From f8a5150e6fa4e40f38b680739a4cc27e95fe4198 Mon Sep 17 00:00:00 2001 From: Roy-043 Date: Sat, 2 Sep 2023 20:48:40 +0200 Subject: [PATCH 1/3] Draft: Fix angle range issue of make_circle --- src/Mod/Draft/draftguitools/gui_arcs.py | 10 +++------- src/Mod/Draft/draftmake/make_circle.py | 5 ++--- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/Mod/Draft/draftguitools/gui_arcs.py b/src/Mod/Draft/draftguitools/gui_arcs.py index a7d458741f..1d0476de5c 100644 --- a/src/Mod/Draft/draftguitools/gui_arcs.py +++ b/src/Mod/Draft/draftguitools/gui_arcs.py @@ -342,13 +342,9 @@ class Arc(gui_base_original.Creator): end = math.degrees(self.firstangle + self.angle) if end < sta: sta, end = end, sta - while True: - if sta > 360: - sta = sta - 360 - elif end > 360: - end = end - 360 - else: - break + sta = sat % 360 + end = end % 360 + try: Gui.addModule("Draft") if utils.getParam("UsePartPrimitives", False): diff --git a/src/Mod/Draft/draftmake/make_circle.py b/src/Mod/Draft/draftmake/make_circle.py index 3e0a148046..f6241844cd 100644 --- a/src/Mod/Draft/draftmake/make_circle.py +++ b/src/Mod/Draft/draftmake/make_circle.py @@ -113,9 +113,8 @@ def make_circle(radius, placement=None, face=None, startangle=None, endangle=Non else: obj.Radius = radius if (startangle is not None) and (endangle is not None): - if startangle == -0: startangle = 0 - obj.FirstAngle = startangle - obj.LastAngle = endangle + obj.FirstAngle = startangle % 360 + obj.LastAngle = endangle % 360 obj.Support = support From e02cfb2f385ee1f62d50df57829a4fa5b59f060b Mon Sep 17 00:00:00 2001 From: Roy-043 Date: Sat, 2 Sep 2023 23:04:41 +0200 Subject: [PATCH 2/3] Typo... --- src/Mod/Draft/draftguitools/gui_arcs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mod/Draft/draftguitools/gui_arcs.py b/src/Mod/Draft/draftguitools/gui_arcs.py index 1d0476de5c..ea172cb8a5 100644 --- a/src/Mod/Draft/draftguitools/gui_arcs.py +++ b/src/Mod/Draft/draftguitools/gui_arcs.py @@ -342,7 +342,7 @@ class Arc(gui_base_original.Creator): end = math.degrees(self.firstangle + self.angle) if end < sta: sta, end = end, sta - sta = sat % 360 + sta = sta % 360 end = end % 360 try: From 3cf51debcafa6e1cfd8f2b8885262b94a150a2ae Mon Sep 17 00:00:00 2001 From: Roy-043 Date: Sun, 3 Sep 2023 12:43:34 +0200 Subject: [PATCH 3/3] Ammended files based on review --- src/Mod/Draft/draftguitools/gui_arcs.py | 4 ++-- src/Mod/Draft/draftmake/make_circle.py | 17 ++++++++++------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/Mod/Draft/draftguitools/gui_arcs.py b/src/Mod/Draft/draftguitools/gui_arcs.py index ea172cb8a5..542b081367 100644 --- a/src/Mod/Draft/draftguitools/gui_arcs.py +++ b/src/Mod/Draft/draftguitools/gui_arcs.py @@ -342,8 +342,8 @@ class Arc(gui_base_original.Creator): end = math.degrees(self.firstangle + self.angle) if end < sta: sta, end = end, sta - sta = sta % 360 - end = end % 360 + sta %= 360 + end %= 360 try: Gui.addModule("Draft") diff --git a/src/Mod/Draft/draftmake/make_circle.py b/src/Mod/Draft/draftmake/make_circle.py index f6241844cd..49532e2fad 100644 --- a/src/Mod/Draft/draftmake/make_circle.py +++ b/src/Mod/Draft/draftmake/make_circle.py @@ -47,6 +47,9 @@ def make_circle(radius, placement=None, face=None, startangle=None, endangle=Non Creates a circle object with given parameters. + If startangle and endangle are provided and not equal, the object will show + an arc instead of a full cirle. + Parameters ---------- radius : the radius of the circle. @@ -58,14 +61,14 @@ def make_circle(radius, placement=None, face=None, startangle=None, endangle=Non If face is False, the circle is shown as a wireframe, otherwise as a face. - startangle : start angle of the arc (in degrees) + startangle : start angle of the circle (in degrees) + Recalculated if not in the -360 to 360 range. - endangle : end angle of the arc (in degrees) - if startangle and endangle are equal, a circle is created, - if they are different an arc is created + endangle : end angle of the circle (in degrees) + Recalculated if not in the -360 to 360 range. edge : edge.Curve must be a 'Part.Circle' - the circle is created from the given edge + The circle is created from the given edge. support : TODO: Describe @@ -113,8 +116,8 @@ def make_circle(radius, placement=None, face=None, startangle=None, endangle=Non else: obj.Radius = radius if (startangle is not None) and (endangle is not None): - obj.FirstAngle = startangle % 360 - obj.LastAngle = endangle % 360 + obj.FirstAngle = math.copysign(abs(startangle) % 360, startangle) + obj.LastAngle = math.copysign(abs(endangle) % 360, endangle) obj.Support = support