Konubinix' site

Printing a Dustbin to Fit in the Cup Holders of My Car

using cadquery

The bottom layer should have a radius of 30 mm, the top layer a radius of 35 mm. It should be 20 mm high at some end and 50 mm high at the other end.

First, make the base cylinder

base = cq.Workplane("XY").circle(lower_radius).workplane(offset=height).circle(upper_radius).loft(combine=True)

Then, from that base, let’s build the top that will be removed, tilted by the appropriate angle so that it remains 2cm.

import math
angle = math.atan(3/6) * 180 / math.pi

top = base.faces(">Z").workplane().transformed(offset=cq.Vector(0, upper_radius, 0), rotate=cq.Vector(angle, 0, 0)).circle(upper_radius * 3).extrude(height, False)

first try shelling with .shell()

Now, lets create a shell out of the base and remove the top.

Trying using the shell feature.

res = base.faces("+Z").shell(-0.001).cut(top)

I could not asked for a 1 mm wide shell, or cadquery would complain about “OCP.StdFail.StdFail_NotDone: BRep_API: command not done”.

Then, I get the following result:

()

bambu-studio complains that the result has manifold issues.

Just out of curiosity, let’s try to remove the cut.

()

bambu-studio likes it

But it tells that it cannot be sliced.

second try, shelling with a copy and a cut

Trying using the inner shell method.

Let’s construct the same mesh, slightly smaller and slightly upper.

ishell = cq.Workplane("XY").workplane(offset=thickness).circle(lower_radius - (thickness / 2)).workplane(offset=height).circle(upper_radius - (thickness / 2)).loft(combine=True)
res = base.cut(ishell).cut(top)

()

The result is much better

final adjustments

By measuring again, I found out the hole dimension are more like

bottom
32mm
top
35mm
bigger height
55mm
smaller height
20mm

Therefore, the final model is more like

()

putting it in the car

I’m quite happy with the result.

side note about the angularTolerance

Beware using a small value for angularTolerance, or it might slice poorly.

For instance, with the defaut value (1).

With 0.5

And with the value 0.1.

side note about the nozzle size

With the thickness=1, the model could not be sliced for a nozzle of 0.6. I needed to increase the thickness to 2 to get it working.

Actually, it make sense because I use a radius of (thickness / 2) for the inner shell. That means that for a thickness of 1, the wall was actually 0.5mm wide. That and thin wall are ignored might explain why it did not work.

slightly bigger

After installing it and knowing what it feels like to use it, we decided that it was too small. Therefore, we decided to print the same thing, but 50mm higher.

Let’s remember the values of:

the upper radius

35

the lower radius

32

the initial height

55

And therefore the new height is

return height + 50
105

And, simply using the intercept theorem, we get the new upper radius.

return ((upper_radius - lower_radius) * new_height) / height + lower_radius
37.72727272727273

And therefore, with the same code with those new values, I obtain this stl file:

()