diff --git a/src/App.tsx b/src/App.tsx
index 341f92a..d03602c 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -347,7 +347,11 @@ function TaskPanel({ workbench, facade, showNotice }: { workbench: Workbench; fa
const isSketch = workbench === 'Sketcher'
const activeTask = facade.task.getActive()
const primitiveType = activeTask?.commandId === 'primitive' && typeof activeTask.draft.primitiveType === 'string' ? activeTask.draft.primitiveType : 'Box'
- return
Active command
{isSketch ? 'Edit Sketch' : definition.taskTitle}
Preview
+ const primitiveFields = primitiveType === 'Box' ? ['width', 'length', 'height'] : primitiveType === 'Cylinder' ? ['radius', 'height', 'angle'] : primitiveType === 'Sphere' ? ['radius'] : ['radius1', 'radius2', 'height', 'angle']
+ 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
}
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 9f2e208..8ae8356 100644
--- a/src/facade/mockFacade.ts
+++ b/src/facade/mockFacade.ts
@@ -303,6 +303,12 @@ 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
+ })
+ }
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 8c95990..ad9f407 100644
--- a/tests/facade.test.ts
+++ b/tests/facade.test.ts
@@ -794,9 +794,12 @@ test('Part workbench commands create primitive and boolean document objects', ()
facade.task.apply()
assert.equal(facade.app.document.getObject('box')?.typeId, 'Part::Box')
facade.gui.command.execute({ commandId: 'primitive' })
- facade.task.update({ primitiveType: 'Cylinder' })
+ facade.task.update({ primitiveType: 'Cylinder', radius: 3, height: 12, angle: 180 })
facade.task.apply()
assert.equal(facade.app.document.getObject('cylinder')?.typeId, 'Part::Cylinder')
+ assert.equal(facade.app.document.getObject('cylinder')?.properties.find((property) => property.name === 'Radius')?.value, 3)
+ assert.equal(facade.app.document.getObject('cylinder')?.properties.find((property) => property.name === 'Height')?.value, 12)
+ assert.equal(facade.app.document.getObject('cylinder')?.properties.find((property) => property.name === 'Angle')?.value, 180)
assert.equal(facade.gui.command.getState('union').status, 'enabled')
facade.gui.command.execute({ commandId: 'union' })