part()
Declares a reusable part: a named body of part-design statements with an
optional param() interface. Returns a LAZY definition — geometry builds
per variant when the definition is inserted (insert(def, { Length: 380 }))
or when the defining file renders standalone:
export const bushing = part('Bushing', () => {
const bore = param('Bore', 10, 'number', { min: 4 });
const s = sketch("xy", () => { circle([0, 0], 30); circle([0, 0], bore); });
const e = extrude(20);
connector('top', e.endFaces());
expose('profile', s);
});
Equal override values share one template per scene (repeat inserts are
cheap); geometry published with expose('name', source) is read back as
def.features.<name> (the callback's return value is ignored).
Every part is exported from the top level of its file, and its name is
unique within the file. A part() nothing exports (or exports only as
default), one written inside another part's or assembly's body, and a
second part of a name the file already used are build errors on that
part(): the part does not build, and its row says why.
Returns: PartDefinition
See the guide for detailed usage examples.
Signatures
part(name: string, callback: () => T): PartDefinition<T>
Declares a reusable part: a named body of part-design statements with an
optional param() interface. Returns a LAZY definition — geometry builds
per variant when the definition is inserted (insert(def, { Length: 380 }))
or when the defining file renders standalone:
export const bushing = part('Bushing', () => {
const bore = param('Bore', 10, 'number', { min: 4 });
const s = sketch("xy", () => { circle([0, 0], 30); circle([0, 0], bore); });
const e = extrude(20);
connector('top', e.endFaces());
expose('profile', s);
});
Equal override values share one template per scene (repeat inserts are
cheap); geometry published with expose('name', source) is read back as
def.features.<name> (the callback's return value is ignored).
Every part is exported from the top level of its file, and its name is
unique within the file. A part() nothing exports (or exports only as
default), one written inside another part's or assembly's body, and a
second part of a name the file already used are build errors on that
part(): the part does not build, and its row says why.
| Parameter | Type | Description |
|---|---|---|
name | string | |
callback | () => T |