Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 15 additions & 12 deletions apps/catalog/app/shared/fusion-library.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,16 @@ const tool = (over: Partial<CatalogTool> = {}): CatalogTool =>
const holder = {
guid: '973eaa5d-4474-46c8-aaac-d89dcefcaa0f',
brand: 'Kennametal',
catalogNumber: 'BT30ER16060M',
noseDiameter: 28,
noseLength: 20,
bodyDiameter: 34,
bodyLength: 15,
catalogNumber: 'BT 30 / PG 6 x 050',
// REGO-FIX's BT30 B4 gage length includes the 48.4 mm spindle-side taper.
// Fusion's holder gage is the sum of the below-spindle segments (B3).
gaugeLength: 98.4,
noseDiameter: 10,
noseLength: 10.55,
bodyDiameter: 12.02,
bodyLength: 9.6,
flangeDiameter: 46,
projection: 60,
gaugeLength: 44,
projection: 50,
} as unknown as Holder

const ids = (): (() => string) => {
Expand All @@ -49,17 +51,17 @@ describe('the order list as a Fusion library', () => {
CSP: false,
HAND: true,
LB: 31,
assemblyGaugeLength: 75,
assemblyGaugeLength: 81,
'shoulder-length': 19,
'shoulder-diameter': 8,
})
expect(first.holder).toMatchObject({
type: 'holder',
gaugeLength: 44,
gaugeLength: 50,
segments: [
{ height: 20, 'lower-diameter': 28, 'upper-diameter': 28 },
{ height: 15, 'lower-diameter': 34, 'upper-diameter': 34 },
{ height: 25, 'lower-diameter': 46, 'upper-diameter': 46 },
{ height: 10.55, 'lower-diameter': 10, 'upper-diameter': 10 },
{ height: 9.6, 'lower-diameter': 12.02, 'upper-diameter': 12.02 },
{ height: 29.85, 'lower-diameter': 46, 'upper-diameter': 46 },
],
})
expect(first['start-values'].presets).toHaveLength(3)
Expand Down Expand Up @@ -171,6 +173,7 @@ describe('the order list as a Fusion library', () => {

expect(result.library.data).toHaveLength(1)
expect(result.library.data[0]?.holder).toBeUndefined()
expect(result.library.data[0]?.geometry.assemblyGaugeLength).toBe(27)
expect(result.holderWarnings[0]?.reason).toContain('no complete published Fusion shape')
})
})
17 changes: 12 additions & 5 deletions apps/catalog/app/shared/fusion-library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,10 @@ const missingGeometry = (tool: CatalogTool): Array<string> => {
return codes.filter((code) => !validNumber(tool.geometry[code]))
}

const geometryOf = (line: LibraryLine): Record<string, number | boolean> => {
const geometryOf = (
line: LibraryLine,
holderGaugeLength: number,
): Record<string, number | boolean> => {
const { tool } = line
const setout = line.stickout ?? tool.geometry.LBH
const geometry: Record<string, number | boolean> = {
Expand All @@ -145,7 +148,7 @@ const geometryOf = (line: LibraryLine): Record<string, number | boolean> => {
LB: setout!,
'shoulder-length': tool.geometry['shoulder-length'] ?? tool.geometry.LCF!,
'shoulder-diameter': tool.geometry['shoulder-diameter'] ?? tool.geometry.SFDM!,
assemblyGaugeLength: setout! + (line.holder?.gaugeLength ?? 0),
assemblyGaugeLength: setout! + holderGaugeLength,
}
for (const code of ['RE', 'SIG', 'TA', 'TP', 'TPX', 'TPN', 'NT', 'tip-diameter'] as const) {
const value = tool.geometry[code]
Expand All @@ -161,17 +164,21 @@ const geometryOf = (line: LibraryLine): Record<string, number | boolean> => {

const holderOf = (holder: Holder, nextGuid: () => string): FusionHolder | null => {
const segments = segmentsOf(holder)
if (segments.length === 0 || !validNumber(holder.gaugeLength)) {
if (segments.length === 0) {
return null
}
// Fusion measures a holder from the sum of the geometry it receives. The
// catalog's gaugeLength can include the spindle-side taper (BT30 B4 does),
// which this deliberately below-spindle silhouette does not export.
const gaugeLength = segments.reduce((total, segment) => total + segment.height, 0)
return {
guid: nextGuid(),
type: 'holder',
unit: 'millimeters',
description: `${holder.brand} ${holder.catalogNumber}`,
vendor: holder.brand,
'product-id': holder.catalogNumber,
gaugeLength: holder.gaugeLength,
gaugeLength,
segments,
}
}
Expand Down Expand Up @@ -249,7 +256,7 @@ export const fusionLibrary = (
'product-id': line.tool.catalogNumber,
...(line.tool.productLink === null ? {} : { 'product-link': line.tool.productLink }),
description: `${line.tool.brand} ${line.tool.catalogNumber}`,
geometry: geometryOf(line),
geometry: geometryOf(line, holder?.gaugeLength ?? 0),
...(holder === null ? {} : { holder }),
'post-process': {
number: at,
Expand Down