WIP: Add bidirectional args to point-and-click Extrude

Will eventually close #7495
This commit is contained in:
Pierre Jacquier
2025-06-16 11:20:57 -04:00
parent 4159cc0047
commit 1a1a152fbf
3 changed files with 30 additions and 1 deletions

View File

@ -37,11 +37,13 @@ export function addExtrude({
ast,
sketches,
length,
symmetric,
nodeToEdit,
}: {
ast: Node<Program>
sketches: Selections
length: KclCommandValue
symmetric?: boolean
nodeToEdit?: PathToNode
}):
| {
@ -63,9 +65,15 @@ export function addExtrude({
return sketchesExprList
}
// Extra labeled args expressions
const symmetricExpr = symmetric
? [createLabeledArg('symmetric', createLiteral(symmetric))]
: []
const sketchesExpr = createSketchExpression(sketchesExprList)
const call = createCallExpressionStdLibKw('extrude', sketchesExpr, [
createLabeledArg('length', valueOrVariable(length)),
...symmetricExpr,
])
// Insert variables for labeled arguments if provided

View File

@ -60,6 +60,8 @@ export type ModelingCommandSchema = {
// KCL stdlib arguments
sketches: Selections
length: KclCommandValue
symmetric?: boolean
// bidirectionalLength?: KclCommandValue
}
Sweep: {
// Enables editing workflow
@ -394,6 +396,24 @@ export const modelingMachineCommandConfig: StateMachineCommandSetConfig<
defaultValue: KCL_DEFAULT_LENGTH,
required: true,
},
symmetric: {
inputType: 'options',
skip: true,
defaultValue: false,
hidden: false,
required: true,
options: [
{ name: 'False', value: false },
{ name: 'True', value: true },
],
},
// bidirectionalLength: {
// inputType: 'kcl',
// defaultValue: KCL_DEFAULT_LENGTH,
// skip: true,
// hidden: false,
// required: false,
// },
},
},
Sweep: {

View File

@ -2429,12 +2429,13 @@ export const modelingMachine = setup({
return Promise.reject(new Error(NO_INPUT_PROVIDED_MESSAGE))
}
const { nodeToEdit, sketches, length } = input
const { nodeToEdit, sketches, length, symmetric } = input
const { ast } = kclManager
const astResult = addExtrude({
ast,
sketches,
length,
symmetric,
nodeToEdit,
})
if (err(astResult)) {