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)
| 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 | """ |