MCPcopy
hub / github.com/CadQuery/cadquery / testSweep

Method testSweep

tests/test_cadquery.py:1063–1213  ·  view source on GitHub ↗

Tests the operation of sweeping a wire(s) along a path

(self)

Source from the content-addressed store, hash-verified

1061 self.assertTrue(el.isValid())
1062
1063 def testSweep(self):
1064 """
1065 Tests the operation of sweeping a wire(s) along a path
1066 """
1067 pts = [(0, 0), (0, 1), (1, 2), (2, 4)]
1068
1069 # Spline path
1070 path = Workplane("XZ").spline(pts)
1071
1072 # Test defaults
1073 result = Workplane("XY").circle(1.0).sweep(path)
1074 self.assertEqual(3, result.faces().size())
1075 self.assertEqual(3, result.edges().size())
1076
1077 # Test Wire path
1078 result = Workplane("XY").circle(1.0).sweep(path.val())
1079 self.assertEqual(3, result.faces().size())
1080 self.assertEqual(3, result.edges().size())
1081
1082 # Test with makeSolid False
1083 result = Workplane("XY").circle(1.0).sweep(path, makeSolid=False)
1084 self.assertEqual(1, result.faces().size())
1085 self.assertEqual(3, result.edges().size())
1086
1087 # Test with isFrenet True
1088 result = Workplane("XY").circle(1.0).sweep(path, isFrenet=True)
1089 self.assertEqual(3, result.faces().size())
1090 self.assertEqual(3, result.edges().size())
1091
1092 # Test with makeSolid False and isFrenet True
1093 result = Workplane("XY").circle(1.0).sweep(path, makeSolid=False, isFrenet=True)
1094 self.assertEqual(1, result.faces().size())
1095 self.assertEqual(3, result.edges().size())
1096
1097 # Test rectangle with defaults
1098 result = Workplane("XY").rect(1.0, 1.0).sweep(path)
1099 self.assertEqual(6, result.faces().size())
1100 self.assertEqual(12, result.edges().size())
1101
1102 # Test fixed normal
1103 result = Workplane().circle(0.5).sweep(path, normal=Vector(0, 0, 1))
1104 self.assertTupleAlmostEquals(
1105 result.faces(">Z").val().normalAt().toTuple(), (0, 0, 1), 6
1106 )
1107
1108 # Polyline path
1109 path = Workplane("XZ").polyline(pts)
1110
1111 # Test defaults
1112 result = Workplane("XY").circle(0.1).sweep(path, transition="transformed")
1113 self.assertEqual(5, result.faces().size())
1114 self.assertEqual(7, result.edges().size())
1115
1116 # Polyline path and one inner profiles
1117 path = Workplane("XZ").polyline(pts)
1118
1119 # Test defaults
1120 result = (

Callers

nothing calls this directly

Calls 15

WorkplaneClass · 0.85
VectorClass · 0.85
polylineMethod · 0.80
isValidMethod · 0.80
threePointArcMethod · 0.80
getAngleMethod · 0.80
vLineMethod · 0.80
hLineMethod · 0.80
boxMethod · 0.80
lineToMethod · 0.80
workplaneMethod · 0.80

Tested by

no test coverage detected