Add twistAng
This commit is contained in:
@ -38,6 +38,7 @@ export function addExtrude({
|
||||
sketches,
|
||||
length,
|
||||
bidirectionalLength,
|
||||
twistAngle,
|
||||
symmetric,
|
||||
nodeToEdit,
|
||||
}: {
|
||||
@ -45,6 +46,7 @@ export function addExtrude({
|
||||
sketches: Selections
|
||||
length: KclCommandValue
|
||||
bidirectionalLength?: KclCommandValue
|
||||
twistAngle?: KclCommandValue
|
||||
symmetric?: boolean
|
||||
nodeToEdit?: PathToNode
|
||||
}):
|
||||
@ -76,6 +78,9 @@ export function addExtrude({
|
||||
),
|
||||
]
|
||||
: []
|
||||
const twistAngleExpr = twistAngle
|
||||
? [createLabeledArg('twistAngle', valueOrVariable(twistAngle))]
|
||||
: []
|
||||
const symmetricExpr = symmetric
|
||||
? [createLabeledArg('symmetric', createLiteral(symmetric))]
|
||||
: []
|
||||
@ -84,6 +89,7 @@ export function addExtrude({
|
||||
const call = createCallExpressionStdLibKw('extrude', sketchesExpr, [
|
||||
createLabeledArg('length', valueOrVariable(length)),
|
||||
...bidirectionalLengthExpr,
|
||||
...twistAngleExpr,
|
||||
...symmetricExpr,
|
||||
])
|
||||
|
||||
|
@ -62,6 +62,7 @@ export type ModelingCommandSchema = {
|
||||
length: KclCommandValue
|
||||
symmetric?: boolean
|
||||
bidirectionalLength?: KclCommandValue
|
||||
twistAngle?: KclCommandValue
|
||||
}
|
||||
Sweep: {
|
||||
// Enables editing workflow
|
||||
@ -410,6 +411,11 @@ export const modelingMachineCommandConfig: StateMachineCommandSetConfig<
|
||||
skip: true,
|
||||
required: false,
|
||||
},
|
||||
twistAngle: {
|
||||
inputType: 'kcl',
|
||||
skip: true,
|
||||
required: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
Sweep: {
|
||||
|
@ -116,6 +116,23 @@ const prepareToEditExtrude: PrepareToEditCallback = async ({ operation }) => {
|
||||
return { reason: "Couldn't retrieve bidirectionalLength argument" }
|
||||
}
|
||||
|
||||
// twistAngle argument from a string to a KCL expression
|
||||
let twistAngle: KclCommandValue | Error | ParseResult | undefined
|
||||
if (
|
||||
'twistAngle' in operation.labeledArgs &&
|
||||
operation.labeledArgs.twistAngle
|
||||
) {
|
||||
twistAngle = await stringToKclExpression(
|
||||
codeManager.code.slice(
|
||||
operation.labeledArgs.twistAngle.sourceRange[0],
|
||||
operation.labeledArgs.twistAngle.sourceRange[1]
|
||||
)
|
||||
)
|
||||
}
|
||||
if (err(twistAngle) || (twistAngle && 'errors' in twistAngle)) {
|
||||
return { reason: "Couldn't retrieve twistAngle argument" }
|
||||
}
|
||||
|
||||
// symmetric argument from a string to boolean
|
||||
let symmetric: boolean | undefined
|
||||
if ('symmetric' in operation.labeledArgs && operation.labeledArgs.symmetric) {
|
||||
@ -133,6 +150,7 @@ const prepareToEditExtrude: PrepareToEditCallback = async ({ operation }) => {
|
||||
sketches,
|
||||
length,
|
||||
bidirectionalLength,
|
||||
twistAngle,
|
||||
symmetric,
|
||||
nodeToEdit: pathToNodeFromRustNodePath(operation.nodePath),
|
||||
}
|
||||
|
@ -2429,14 +2429,21 @@ export const modelingMachine = setup({
|
||||
return Promise.reject(new Error(NO_INPUT_PROVIDED_MESSAGE))
|
||||
}
|
||||
|
||||
const { nodeToEdit, sketches, length, bidirectionalLength, symmetric } =
|
||||
input
|
||||
const {
|
||||
nodeToEdit,
|
||||
sketches,
|
||||
length,
|
||||
bidirectionalLength,
|
||||
twistAngle,
|
||||
symmetric,
|
||||
} = input
|
||||
const { ast } = kclManager
|
||||
const astResult = addExtrude({
|
||||
ast,
|
||||
sketches,
|
||||
length,
|
||||
bidirectionalLength,
|
||||
twistAngle,
|
||||
symmetric,
|
||||
nodeToEdit,
|
||||
})
|
||||
|
Reference in New Issue
Block a user