Flanged Part - 3D CAD Model
blueprint

Flanged Part - 3D CAD Model

FlowCad is the fast, free, and precise web app for 3D design and printing. Build professional parametric models with ease-no programming required, but it's there if you need it.

3D Model Components

Blueprint Script (TypeScript)

/*
 * Parametric Flanged Cylinder with Mounting Holes
 * Converted to Manifold-3D style
 */

// 1. Define Defaults (these appear in the properties panel)
const PARAMS = {
    radius:        3.0,
    height:        15.0,
    wallThickness: 1.5,
    flangeThickness: 2.0,
    screwHoleRadius: 1.0,
    screwPatternRadius: 5.0,   // distance from center to screw hole centers
};

// 2. Extract parameters (destructuring – cleaner & more idiomatic)
let {
    radius,
    height,
    wallThickness,
    flangeThickness,
    screwHoleRadius,
    screwPatternRadius,
} = PARAMS;
let screwPatternRadius2 = screwPatternRadius  + radius
// ────────────────────────────────────────────────
// 3. Main cylinder (outer body)
const outerCylinder = Manifold.cylinder(
    height,           // height
    radius,           // radius top
    radius,           // radius bottom
    64,               // circularSegments – smooth but not excessive
    true              // center = true → centered at origin
);

// ────────────────────────────────────────────────
// 4. Inner hollow cylinder (slightly taller to guarantee clean cut)
const innerRadius = radius - wallThickness;
const innerCylinder = Manifold.cylinder(
    height + 4,       // generous extra height
    innerRadius,
    innerRadius,
    64,
    true
).translate([0, 0, -2]);   // shift down so it fully pierces top & bottom

// ────────────────────────────────────────────────
// 5. Four screw holes – positioned in a square pattern
const holeHeight = height + 10;   // very tall → guaranteed clean subtraction

const holeProto = Manifold.cylinder(
    holeHeight,
    screwHoleRadius,
    screwHoleRadius,
    32,
    true
);

// Positions: square rotated 45° (more symmetric for round flange)
let k = screwPatternRadius - screwHoleRadius*2
const offsets = [
    [0,  radius + k],
    [radius + k,0],
    [0, -radius - k],
    [-radius - k,0]
];

let allHoles = Manifold.cylinder(1, 0.1, 0.1, 8, true); // dummy tiny object

for (const [x, y] of offsets) {
    const movedHole = holeProto.translate([x, y, -holeHeight/2 + flangeThickness/2]);
    allHoles = allHoles.add(movedHole);
}

// ────────────────────────────────────────────────
// 6. Flange / base plate (thicker disk at bottom)
const flange = Manifold.cylinder(
    flangeThickness,
    screwPatternRadius2,   // large enough to contain screw holes nicely
    screwPatternRadius2,
    64,
    false                       // **not** centered → bottom at z=0
);

// Move flange so its top surface sits at z = -height/2
const flangeMoved = flange.translate([0, 0, -height/2 - flangeThickness]);

// ────────────────────────────────────────────────
// 7. Combine solid parts first (union)
let solid = outerCylinder.add(flangeMoved);

// 8. Subtract all cutouts in one go
const cutouts = innerCylinder.add(allHoles);
const finalPart = solid.subtract(cutouts);

// ────────────────────────────────────────────────
// 9. Return result + current parameters
return {
    result: finalPart,
    PARAMS
};