Design for moulding
Design parts that will come out of a mould: injection-moulded plastic,
urethane cast in silicone, or die-cast aluminium and zinc. You pick a
material, and the library sets the wall, draft, rib and boss sizes for you.
Its DFM check then reports what a moulder would flag. This is the
cadbuildr-moulding library, built on Foundation.
Prerequisites: pip install cadbuildr-moulding (it installs
cadbuildr-foundation and cadbuildr-stdlib).
Build a moulded enclosure
from cadbuildr.foundation import show
from cadbuildr.moulding import MouldedEnclosure, format_report
box = MouldedEnclosure(material="ABS") # housing + lid + four M3 screws
print(format_report(box.dfm()))
show(box)MouldedEnclosure is an Assembly. It holds a MouldedHousing (open-top
box with four gusseted screw bosses, floor ribs and a cable notch), a
MouldedLid (locating lip, clearance holes, raised label, resin code
underneath) and four DIN 912 screws. The parts are joined by interfaces, so
check() runs on every build, and the viewer’s status bar shows the DFM
issues of both parts next to the joint checks.
Leave wall and draft empty to use the material’s values. Set
closure="snaps" to swap the screws for two cantilever snap hooks.
Change the material, re-check the geometry
compare checks the same part against several materials:
from cadbuildr.moulding import MouldedHousing, compare, format_report
h = MouldedHousing(material="ABS", rib_thickness=1.2)
for mat, issues in compare(h, "ABS", "PP").items():
print(format_report([i for i in issues if i["severity"] != "info"], mat))ABS: 0 error(s), 0 warning(s), 0 info
PP: 0 error(s), 6 warning(s), 0 info
[warning] rib.thick: rib_1: rib 1.2 mm is 60% of the 2 mm wall (> 50% for PP): sink marks opposite the rib -> rib root <= 1.00 mm
...
[warning] boss.pilot: boss_1: pilot 2.4 mm vs 2.10 mm for M3 in PP -> pilot 2.10 mmMaterials
| Material | Process | Wall (min–max, nominal) | Draft | Rib / wall | Shrinkage |
|---|---|---|---|---|---|
| ABS | injection | 1.2–3.5, 2.0 | 1.0° | 60 % | 0.6 % |
| PC | injection | 1.0–3.8, 2.5 | 1.0° | 60 % | 0.6 % |
| PP | injection | 0.9–3.8, 1.8 | 1.0° | 50 % | 1.5 % |
| PA6 / PA66-GF30 / POM | injection | 0.8–3.0 | 0.5–1.0° | 50 % | 0.5–2.0 % |
| CastPU-70D | casting in silicone | 1.5–6.0, 2.5 | 0.5° | 70 % | 0.15 % |
| Al-A380 / Zamak-3 | die-casting | 1.0–5.0 / 0.5–4.0 | 1.0° / 0.5° | 80 % | 0.6–0.7 % |
PC/ABS, HDPE, PMMA and TPU-90A are in the table too (MATERIALS). The
helpers return the numbers a feature uses:
from cadbuildr.moulding import boss_for, rib_for, draft_for, snap_fit
boss_for("M3", "PC") # {'d': 3.0, 'pilot': 2.55, 'od': 7.5, 'engage': 6.6}
rib_for("PP") # {'thickness': 0.9, 'max_height': 5.4, 'min_spacing': 3.6, 'root_radius': 0.45}
draft_for("ABS", texture_depth=0.05) # 3.0 degrees
snap_fit("ABS", length=14, thickness=1.6, width=8, undercut=1.0)["strain"] # 1.22 %Add features to your own part
Declare the part moulded, then add features. Each feature records itself,
and check(part) reads those records:
from cadbuildr.foundation import Part
from cadbuildr.moulding import (moulded, drafted_shell, add_rib, add_screw_boss,
add_snap_hook, check, format_report, get_material)
class Cover(Part):
def __init__(self, material="ABS"):
m = get_material(material)
moulded(self, material)
body, _ = drafted_shell(self, 100, 60, 20, m.wall, m.draft, radius=5)
self.add_operation(body)
add_rib(self, "x", 0, -45, 45, z0=m.wall)
add_screw_boss(self, 40, 20, z0=m.wall, height=18 - m.wall, screw="M3")
add_snap_hook(self, 0, 25, z0=m.wall, direction="+y", undercut=0.8)
print(format_report(check(Cover("PC"))))The mould opens along +Z of the part. Features stand on planes z = const.
| Operation | What it builds |
|---|---|
add_draft, drafted_box, drafted_shell | drafted side faces, an open box with a uniform drafted wall |
shell_uniform | a uniform wall (native shell) |
add_rib | a drafted rib with root fillets, root = rib ratio × wall |
add_screw_boss | a boss for a thread-forming screw with gussets and a threaded ScrewHole |
add_snap_hook | a cantilever hook with its strain checked and a shut-off window under the lip |
add_living_hinge | a thin-web hinge groove (PP / PE) |
core_out, declare_section | pocket a thick section; record one the check must see |
emboss_text | raised or engraved text |
add_wall_opening | a port through a side wall (a notch open to the rim, or a window that needs a side action) |
add_ejector_pad, mark_gate, mark_vent | tooling marks (anchors + records) |
DFM check codes
| Code | Severity | Meaning |
|---|---|---|
wall.thin / wall.thick | error / warning | wall outside the material’s range |
draft.missing / draft.low | error / warning | no draft, or less than the material needs (texture included) |
rib.thick / rib.tall / rib.spacing | warning | sink marks, rib taller than 3 × wall, ribs closer than 2 × wall |
boss.od / boss.sink / boss.tall / boss.engage / boss.pilot | warning | boss would split, sink, wobble or strip |
undercut | warning | feature locks in the pull direction (needs a side action or lifter) |
snap.strain / snap.material | error | hook over-strained, or a die-cast part |
hinge.material | error | living hinge in anything but PP / PE |
section.thick, corner.sharp, text.draft | warning | thick section not cored, sharp inside corner, text without draft |
Make a mould
from cadbuildr.moulding import SiliconeMould, CoreCavityMould
# 2-part silicone mould for casting resin: keys, pour sprue, vents, pour box
SiliconeMould(master="pawn", material="CastPU-70D", wall=10, opening=30, pour_box=True)
# injection inserts around the housing, grown by the material's shrinkage
CoreCavityMould(master="housing", material="PP", opening=40)The two halves are joined by PartingFace interfaces with a slider joint,
so opening lifts the top half off. Masters are pawn, knob, capsule
(turned parts, parted through their axis) and housing (an open box parted
at the rim; its inside belongs to the core half).
The check reads what the library built. Python does not see the kernel’s
finished solid, so it cannot spot draft or thin walls that you model by hand.
Record that geometry with declare_section or record.