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