Tests a plugin that combines cubes together with a base :return:
(self)
| 135 | ) |
| 136 | |
| 137 | def testCubePlugin(self): |
| 138 | """ |
| 139 | Tests a plugin that combines cubes together with a base |
| 140 | :return: |
| 141 | """ |
| 142 | # make the plugin method |
| 143 | |
| 144 | def makeCubes(self, length): |
| 145 | # self refers to the CQ or Workplane object |
| 146 | |
| 147 | # create the solid |
| 148 | s = Solid.makeBox(length, length, length, Vector(0, 0, 0)) |
| 149 | |
| 150 | # use CQ utility method to iterate over the stack an position the cubes |
| 151 | return self.eachpoint(lambda loc: s.located(loc), True) |
| 152 | |
| 153 | # link the plugin in |
| 154 | Workplane.makeCubes = makeCubes |
| 155 | |
| 156 | # call it |
| 157 | result = ( |
| 158 | Workplane("XY") |
| 159 | .box(6.0, 8.0, 0.5) |
| 160 | .faces(">Z") |
| 161 | .rect(4.0, 4.0, forConstruction=True) |
| 162 | .vertices() |
| 163 | ) |
| 164 | result = result.makeCubes(1.0) |
| 165 | result = result.combine() |
| 166 | self.saveModel(result) |
| 167 | self.assertEqual(1, result.size()) |
| 168 | self.assertEqual("Compound", result.val().ShapeType()) |
| 169 | self.assertEqual(4, result.solids().size()) |
| 170 | |
| 171 | def testCylinderPlugin(self): |
| 172 | """ |
nothing calls this directly
no test coverage detected