Skip to content

Commit fccceda

Browse files
committed
Tests & Edge.intersections
1 parent b5de144 commit fccceda

File tree

5 files changed

+227
-131
lines changed

5 files changed

+227
-131
lines changed

src/build123d/__init__.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,21 @@
1414
"FT",
1515
# Enums
1616
"Align",
17-
"Select",
18-
"Kind",
17+
"AngularDirection",
18+
"CenterOf",
19+
"Direction",
20+
"FontStyle",
21+
"FrameMethod",
22+
"GeomType",
1923
"Keep",
24+
"Kind",
25+
"LengthMode",
2026
"Mode",
27+
"PositionMode",
28+
"Select",
29+
"SortBy",
2130
"Transition",
22-
"FontStyle",
2331
"Until",
24-
"SortBy",
25-
"GeomType",
26-
"AngularDirection",
27-
"PositionMode",
28-
"FrameMethod",
29-
"Direction",
30-
"CenterOf",
3132
# Classes
3233
"Rotation",
3334
"RotationLike",

src/build123d/build_enums.py

Lines changed: 88 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -40,125 +40,123 @@ def __repr__(self):
4040
return f"<{self.__class__.__name__}.{self.name}>"
4141

4242

43-
class Select(Enum):
44-
"""Selector scope - all or last operation"""
43+
class AngularDirection(Enum):
44+
"""Angular rotation direction"""
4545

46-
ALL = auto()
47-
LAST = auto()
46+
CLOCKWISE = auto()
47+
COUNTER_CLOCKWISE = auto()
4848

4949
def __repr__(self):
5050
return f"<{self.__class__.__name__}.{self.name}>"
5151

5252

53-
class Kind(Enum):
54-
"""Offset corner transition"""
53+
class CenterOf(Enum):
54+
"""Center Options"""
5555

56-
ARC = auto()
57-
INTERSECTION = auto()
58-
TANGENT = auto()
56+
GEOMETRY = auto()
57+
MASS = auto()
58+
BOUNDING_BOX = auto()
5959

6060
def __repr__(self):
6161
return f"<{self.__class__.__name__}.{self.name}>"
6262

6363

64-
class Keep(Enum):
65-
"""Split options"""
64+
class Direction(Enum):
65+
"""Face direction"""
6666

67-
TOP = auto()
68-
BOTTOM = auto()
69-
BOTH = auto()
67+
ALONG_AXIS = auto()
68+
OPPOSITE = auto()
7069

7170
def __repr__(self):
7271
return f"<{self.__class__.__name__}.{self.name}>"
7372

7473

75-
class Mode(Enum):
76-
"""Combination Mode"""
74+
class FrameMethod(Enum):
75+
"""Moving frame calculation method"""
7776

78-
ADD = auto()
79-
SUBTRACT = auto()
80-
INTERSECT = auto()
81-
REPLACE = auto()
82-
PRIVATE = auto()
77+
FRENET = auto()
78+
CORRECTED = auto()
8379

8480
def __repr__(self):
8581
return f"<{self.__class__.__name__}.{self.name}>"
8682

8783

88-
class Transition(Enum):
89-
"""Sweep discontinuity handling option"""
84+
class GeomType(Enum):
85+
"""CAD geometry object type"""
9086

91-
RIGHT = auto()
92-
ROUND = auto()
93-
TRANSFORMED = auto()
87+
PLANE = auto()
88+
CYLINDER = auto()
89+
CONE = auto()
90+
SPHERE = auto()
91+
TORUS = auto()
92+
BEZIER = auto()
93+
BSPLINE = auto()
94+
REVOLUTION = auto()
95+
EXTRUSION = auto()
96+
OFFSET = auto()
97+
LINE = auto()
98+
CIRCLE = auto()
99+
ELLIPSE = auto()
100+
HYPERBOLA = auto()
101+
PARABOLA = auto()
102+
OTHER = auto()
94103

95104
def __repr__(self):
96105
return f"<{self.__class__.__name__}.{self.name}>"
97106

98107

99-
class FontStyle(Enum):
100-
"""Text Font Styles"""
108+
class Keep(Enum):
109+
"""Split options"""
101110

102-
REGULAR = auto()
103-
BOLD = auto()
104-
ITALIC = auto()
111+
TOP = auto()
112+
BOTTOM = auto()
113+
BOTH = auto()
105114

106115
def __repr__(self):
107116
return f"<{self.__class__.__name__}.{self.name}>"
108117

109118

110-
class Until(Enum):
111-
"""Extrude limit"""
119+
class Kind(Enum):
120+
"""Offset corner transition"""
112121

113-
NEXT = auto()
114-
LAST = auto()
122+
ARC = auto()
123+
INTERSECTION = auto()
124+
TANGENT = auto()
115125

116126
def __repr__(self):
117127
return f"<{self.__class__.__name__}.{self.name}>"
118128

119129

120-
class SortBy(Enum):
121-
"""Sorting criteria"""
130+
class Mode(Enum):
131+
"""Combination Mode"""
122132

123-
LENGTH = auto()
124-
RADIUS = auto()
125-
AREA = auto()
126-
VOLUME = auto()
127-
DISTANCE = auto()
133+
ADD = auto()
134+
SUBTRACT = auto()
135+
INTERSECT = auto()
136+
REPLACE = auto()
137+
PRIVATE = auto()
128138

129139
def __repr__(self):
130140
return f"<{self.__class__.__name__}.{self.name}>"
131141

132142

133-
class GeomType(Enum):
134-
"""CAD geometry object type"""
143+
class FontStyle(Enum):
144+
"""Text Font Styles"""
135145

136-
PLANE = auto()
137-
CYLINDER = auto()
138-
CONE = auto()
139-
SPHERE = auto()
140-
TORUS = auto()
141-
BEZIER = auto()
142-
BSPLINE = auto()
143-
REVOLUTION = auto()
144-
EXTRUSION = auto()
145-
OFFSET = auto()
146-
LINE = auto()
147-
CIRCLE = auto()
148-
ELLIPSE = auto()
149-
HYPERBOLA = auto()
150-
PARABOLA = auto()
151-
OTHER = auto()
146+
REGULAR = auto()
147+
BOLD = auto()
148+
ITALIC = auto()
152149

153150
def __repr__(self):
154151
return f"<{self.__class__.__name__}.{self.name}>"
155152

156153

157-
class AngularDirection(Enum):
158-
"""Angular rotation direction"""
154+
class LengthMode(Enum):
155+
"""Method of specifying length along PolarLine"""
159156

160-
CLOCKWISE = auto()
161-
COUNTER_CLOCKWISE = auto()
157+
DIAGONAL = auto()
158+
HORIZONTAL = auto()
159+
VERTICAL = auto()
162160

163161
def __repr__(self):
164162
return f"<{self.__class__.__name__}.{self.name}>"
@@ -174,32 +172,45 @@ def __repr__(self):
174172
return f"<{self.__class__.__name__}.{self.name}>"
175173

176174

177-
class FrameMethod(Enum):
178-
"""Moving frame calculation method"""
175+
class Select(Enum):
176+
"""Selector scope - all or last operation"""
179177

180-
FRENET = auto()
181-
CORRECTED = auto()
178+
ALL = auto()
179+
LAST = auto()
182180

183181
def __repr__(self):
184182
return f"<{self.__class__.__name__}.{self.name}>"
185183

186184

187-
class Direction(Enum):
188-
"""Face direction"""
185+
class SortBy(Enum):
186+
"""Sorting criteria"""
189187

190-
ALONG_AXIS = auto()
191-
OPPOSITE = auto()
188+
LENGTH = auto()
189+
RADIUS = auto()
190+
AREA = auto()
191+
VOLUME = auto()
192+
DISTANCE = auto()
192193

193194
def __repr__(self):
194195
return f"<{self.__class__.__name__}.{self.name}>"
195196

196197

197-
class CenterOf(Enum):
198-
"""Center Options"""
198+
class Transition(Enum):
199+
"""Sweep discontinuity handling option"""
199200

200-
GEOMETRY = auto()
201-
MASS = auto()
202-
BOUNDING_BOX = auto()
201+
RIGHT = auto()
202+
ROUND = auto()
203+
TRANSFORMED = auto()
204+
205+
def __repr__(self):
206+
return f"<{self.__class__.__name__}.{self.name}>"
207+
208+
209+
class Until(Enum):
210+
"""Extrude limit"""
211+
212+
NEXT = auto()
213+
LAST = auto()
203214

204215
def __repr__(self):
205216
return f"<{self.__class__.__name__}.{self.name}>"

src/build123d/build_line.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
import inspect
3030
from math import sin, cos, radians, sqrt, copysign
3131
from typing import Union, Iterable
32-
from build123d.build_enums import Select, Mode, AngularDirection
32+
from build123d.build_enums import AngularDirection, LengthMode, Mode, Select
3333
from build123d.direct_api import (
3434
Axis,
3535
Edge,
@@ -569,6 +569,7 @@ class PolarLine(Edge):
569569
length (float): line length
570570
angle (float, optional): angle from +v X axis. Defaults to None.
571571
direction (VectorLike, optional): vector direction. Defaults to None.
572+
length_mode (LengthMode, optional):
572573
mode (Mode, optional): combination mode. Defaults to Mode.ADD.
573574
574575
Raises:
@@ -583,13 +584,19 @@ def __init__(
583584
length: float,
584585
angle: float = None,
585586
direction: VectorLike = None,
587+
length_mode: LengthMode = LengthMode.DIAGONAL,
586588
mode: Mode = Mode.ADD,
587589
):
588590
context: BuildLine = BuildLine._get_context(self)
589591
context.validate_inputs(self)
590592

591593
start = WorkplaneList.localize(start)
592594

595+
if length_mode == LengthMode.HORIZONTAL:
596+
length = length / cos(radians(angle))
597+
elif length_mode == LengthMode.VERTICAL:
598+
length = length / sin(radians(angle))
599+
593600
if angle is not None:
594601
x_val = cos(radians(angle)) * length
595602
y_val = sin(radians(angle)) * length

0 commit comments

Comments
 (0)