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

Method testCup

tests/test_cadquery.py:3223–3268  ·  view source on GitHub ↗

UOM = "mm" # # PARAMETERS and PRESETS # These parameters can be manipulated by end users # bottomDiameter = FloatParam(min=10.0,presets={'default':50.0,'tumbler':50.0,'shot':35.0,'tea':50.0,'saucer':100.0},group="Basics", desc="Bottom diameter")

(self)

Source from the content-addressed store, hash-verified

3221 self.assertTrue(box1.val().BoundingBox().isInside(box2.val().BoundingBox()))
3222
3223 def testCup(self):
3224 """
3225 UOM = "mm"
3226
3227 #
3228 # PARAMETERS and PRESETS
3229 # These parameters can be manipulated by end users
3230 #
3231 bottomDiameter = FloatParam(min=10.0,presets={'default':50.0,'tumbler':50.0,'shot':35.0,'tea':50.0,'saucer':100.0},group="Basics", desc="Bottom diameter")
3232 topDiameter = FloatParam(min=10.0,presets={'default':85.0,'tumbler':85.0,'shot':50.0,'tea':51.0,'saucer':400.0 },group="Basics", desc="Top diameter")
3233 thickness = FloatParam(min=0.1,presets={'default':2.0,'tumbler':2.0,'shot':2.66,'tea':2.0,'saucer':2.0},group="Basics", desc="Thickness")
3234 height = FloatParam(min=1.0,presets={'default':80.0,'tumbler':80.0,'shot':59.0,'tea':125.0,'saucer':40.0},group="Basics", desc="Overall height")
3235 lipradius = FloatParam(min=1.0,presets={'default':1.0,'tumbler':1.0,'shot':0.8,'tea':1.0,'saucer':1.0},group="Basics", desc="Lip Radius")
3236 bottomThickness = FloatParam(min=1.0,presets={'default':5.0,'tumbler':5.0,'shot':10.0,'tea':10.0,'saucer':5.0},group="Basics", desc="BottomThickness")
3237
3238 #
3239 # Your build method. It must return a solid object
3240 #
3241 def build():
3242 br = bottomDiameter.value / 2.0
3243 tr = topDiameter.value / 2.0
3244 t = thickness.value
3245 s1 = Workplane("XY").circle(br).workplane(offset=height.value).circle(tr).loft()
3246 s2 = Workplane("XY").workplane(offset=bottomThickness.value).circle(br - t ).workplane(offset=height.value - t ).circle(tr - t).loft()
3247
3248 cup = s1.cut(s2)
3249 cup.faces(">Z").edges().fillet(lipradius.value)
3250 return cup
3251 """
3252
3253 # for some reason shell doesn't work on this simple shape. how disappointing!
3254 td = 50.0
3255 bd = 20.0
3256 h = 10.0
3257 t = 1.0
3258 s1 = Workplane("XY").circle(bd).workplane(offset=h).circle(td).loft()
3259 s2 = (
3260 Workplane("XY")
3261 .workplane(offset=t)
3262 .circle(bd - (2.0 * t))
3263 .workplane(offset=(h - t))
3264 .circle(td - (2.0 * t))
3265 .loft()
3266 )
3267 s3 = s1.cut(s2)
3268 self.saveModel(s3)
3269
3270 def testEnclosure(self):
3271 """

Callers

nothing calls this directly

Calls 6

saveModelMethod · 0.95
WorkplaneClass · 0.85
loftMethod · 0.80
workplaneMethod · 0.80
circleMethod · 0.45
cutMethod · 0.45

Tested by

no test coverage detected