Foundation (Python)LibrariesDesign for moulding

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 mm

Materials

MaterialProcessWall (min–max, nominal)DraftRib / wallShrinkage
ABSinjection1.2–3.5, 2.01.0°60 %0.6 %
PCinjection1.0–3.8, 2.51.0°60 %0.6 %
PPinjection0.9–3.8, 1.81.0°50 %1.5 %
PA6 / PA66-GF30 / POMinjection0.8–3.00.5–1.0°50 %0.5–2.0 %
CastPU-70Dcasting in silicone1.5–6.0, 2.50.5°70 %0.15 %
Al-A380 / Zamak-3die-casting1.0–5.0 / 0.5–4.01.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.

OperationWhat it builds
add_draft, drafted_box, drafted_shelldrafted side faces, an open box with a uniform drafted wall
shell_uniforma uniform wall (native shell)
add_riba drafted rib with root fillets, root = rib ratio × wall
add_screw_bossa boss for a thread-forming screw with gussets and a threaded ScrewHole
add_snap_hooka cantilever hook with its strain checked and a shut-off window under the lip
add_living_hingea thin-web hinge groove (PP / PE)
core_out, declare_sectionpocket a thick section; record one the check must see
emboss_textraised or engraved text
add_wall_openinga 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_venttooling marks (anchors + records)

DFM check codes

CodeSeverityMeaning
wall.thin / wall.thickerror / warningwall outside the material’s range
draft.missing / draft.lowerror / warningno draft, or less than the material needs (texture included)
rib.thick / rib.tall / rib.spacingwarningsink marks, rib taller than 3 × wall, ribs closer than 2 × wall
boss.od / boss.sink / boss.tall / boss.engage / boss.pilotwarningboss would split, sink, wobble or strip
undercutwarningfeature locks in the pull direction (needs a side action or lifter)
snap.strain / snap.materialerrorhook over-strained, or a die-cast part
hinge.materialerrorliving hinge in anything but PP / PE
section.thick, corner.sharp, text.draftwarningthick 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.