diff --git a/src/App.tsx b/src/App.tsx index 30857f7..dc5435f 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -351,7 +351,16 @@ function TaskPanel({ workbench, facade, showNotice }: { workbench: Workbench; fa const primitiveUnits: Record = { width: 'mm', length: 'mm', height: 'mm', radius: 'mm', radius1: 'mm', radius2: 'mm', angle: 'deg' } const primitiveFallbacks: Record = { width: 10, length: 10, height: 10, radius: 5, radius1: 5, radius2: 0, angle: 360 } const primitiveLabel = (field: string) => field === 'radius1' ? 'Bottom radius' : field === 'radius2' ? 'Top radius' : field[0].toUpperCase() + field.slice(1) - return
Active command

{isSketch ? 'Edit Sketch' : definition.taskTitle}

Preview
1
{isSketch ? 'Geometry and constraints' : definition.objectType}{definition.taskSummary}
{activeTask?.commandId === 'primitive' && <>{primitiveFields.map((field) => )}}{activeTask?.commandId !== 'primitive' && <>}
Changes remain local until the document is recomputed.
+ const featureFields: Record = { + pad: { key: 'length', label: 'Length', unit: 'mm', fallback: 42 }, + pocket: { key: 'length', label: 'Length', unit: 'mm', fallback: 18 }, + revolution: { key: 'angle', label: 'Angle', unit: 'deg', fallback: 360 }, + fillet: { key: 'radius', label: 'Radius', unit: 'mm', fallback: 3 }, + chamfer: { key: 'distance', label: 'Distance', unit: 'mm', fallback: 2 }, + } + const currentFeatureField = activeTask?.commandId ? featureFields[activeTask.commandId] : undefined + const activeCommand = activeTask?.commandId + return
Active command

{isSketch ? 'Edit Sketch' : definition.taskTitle}

Preview
1
{isSketch ? 'Geometry and constraints' : definition.objectType}{definition.taskSummary}
{activeCommand === 'primitive' && <>{primitiveFields.map((field) => )}}{currentFeatureField && }{activeCommand === 'pocket' && }{['pad', 'pocket', 'revolution'].includes(activeCommand || '') && }{activeCommand === 'pad' && }{!activeCommand || activeCommand === 'create-sketch' ? <> : null}
Changes remain local until the document is recomputed.
} function PropertyPanel({ facade, objectId, scope, showNotice }: { facade: BitBybitWebCadFacade; objectId: string; scope: 'data' | 'view'; showNotice: (message: string) => void }) { diff --git a/src/facade/mockFacade.ts b/src/facade/mockFacade.ts index 8ae8356..edcdc91 100644 --- a/src/facade/mockFacade.ts +++ b/src/facade/mockFacade.ts @@ -303,12 +303,14 @@ export function createMockFacade(): BitBybitWebCadFacade { tree.push(item) } const objectSnapshot = createObjectSnapshot(item) - if (commandId === 'primitive') { - objectSnapshot.properties = objectSnapshot.properties.map((property) => { - const candidate = draft[property.name.toLowerCase()] - return typeof candidate === 'number' && Number.isFinite(candidate) ? { ...property, value: candidate } : property - }) - } + objectSnapshot.properties = objectSnapshot.properties.map((property) => { + if (!property.recompute || property.type === 'App::PropertyLink') return property + const candidate = draft[property.name.toLowerCase()] + if (property.type === 'App::PropertyBool' && typeof candidate === 'boolean') return { ...property, value: candidate } + if ((property.type === 'App::PropertyLength' || property.type === 'App::PropertyAngle' || property.type === 'App::PropertyPercent' || property.type === 'App::PropertyFloat') && typeof candidate === 'number' && Number.isFinite(candidate)) return { ...property, value: candidate } + if (property.type === 'App::PropertyEnumeration' && typeof candidate === 'string' && property.options?.includes(candidate)) return { ...property, value: candidate } + return property + }) if (isPartObject && commandId !== 'primitive') { objectSnapshot.properties = objectSnapshot.properties.map((property) => property.name === 'Base' && state.selectedObjectId ? { ...property, value: state.selectedObjectId } : property) } diff --git a/tests/facade.test.ts b/tests/facade.test.ts index ad9f407..99dc361 100644 --- a/tests/facade.test.ts +++ b/tests/facade.test.ts @@ -758,7 +758,7 @@ test('Part Design feature tasks commit a document object and remain undoable', ( const before = facade.app.document.getActive() facade.gui.command.execute({ commandId: 'pad' }) assert.equal(facade.task.getActive()?.commandId, 'pad') - facade.task.update({ length: 42, reversed: false }) + facade.task.update({ length: 55, reversed: true, midplane: true }) facade.task.apply() const committed = facade.app.document.getActive() @@ -767,6 +767,9 @@ test('Part Design feature tasks commit a document object and remain undoable', ( assert.equal(committed.version, before.version + 1) assert.equal(facade.selection.getObjectId(), 'pad001') assert.equal(committed.dirty, true) + assert.equal(committed.objects.find((object) => object.id === 'pad001')?.properties.find((property) => property.name === 'Length')?.value, 55) + assert.equal(committed.objects.find((object) => object.id === 'pad001')?.properties.find((property) => property.name === 'Reversed')?.value, true) + assert.equal(committed.objects.find((object) => object.id === 'pad001')?.properties.find((property) => property.name === 'Midplane')?.value, true) facade.history.undo() assert.equal(facade.app.document.getActive().tree.some((item) => item.id === 'pad001'), false)