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

Method testCylinderPlugin

tests/test_cadquery.py:171–199  ·  view source on GitHub ↗

Tests a cylinder plugin. The plugin creates cylinders of the specified radius and height for each item on the stack This is a very short plugin that illustrates just about the simplest possible plugin

(self)

Source from the content-addressed store, hash-verified

169 self.assertEqual(4, result.solids().size())
170
171 def testCylinderPlugin(self):
172 """
173 Tests a cylinder plugin.
174 The plugin creates cylinders of the specified radius and height for each item on the stack
175
176 This is a very short plugin that illustrates just about the simplest possible
177 plugin
178 """
179
180 def cylinders(self, radius, height):
181
182 # construct a cylinder at (0,0,0)
183 c = Solid.makeCylinder(radius, height, Vector(0, 0, 0))
184
185 # combine all the cylinders into a single compound
186 r = self.eachpoint(lambda loc: c.located(loc), True).union()
187 return r
188
189 Workplane.cyl = cylinders
190
191 # now test. here we want weird workplane to see if the objects are transformed right
192 s = (
193 Workplane(Plane(Vector((0, 0, 0)), Vector((1, -1, 0)), Vector((1, 1, 0))))
194 .rect(2.0, 3.0, forConstruction=True)
195 .vertices()
196 .cyl(0.25, 0.5)
197 )
198 self.assertEqual(4, s.solids().size())
199 self.saveModel(s)
200
201 def testPolygonPlugin(self):
202 """

Callers

nothing calls this directly

Calls 8

saveModelMethod · 0.95
WorkplaneClass · 0.85
PlaneClass · 0.85
VectorClass · 0.85
verticesMethod · 0.45
rectMethod · 0.45
sizeMethod · 0.45
solidsMethod · 0.45

Tested by

no test coverage detected