Add edit flow for Shell thickness (#5525)
* WIP: Add edit flow for Shell thickness Would fix #5406 but not like this :sad: * Early win with working edit on shell * Extend to logic to walls with tags * Remove skip * Add wall test * Fixing inconsistencies in code. Tests not working on win * Refactor addShell for consitency * Clean up * More clean up * Add validation on both params * A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores) * Passing tests * Prettier * Change from test.skip to comment * Clean up for review * Add review suggestions and disable thickness validator * A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores) * A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores) * Remove uneccessary changes * Add edit flow for Shell thickness Fixes #5406 * Enable edit step in test that works only if the start code is properly formatted * Clean up for review --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
@ -457,6 +457,64 @@ export function loftSketches(
|
||||
}
|
||||
}
|
||||
|
||||
export function addShell({
|
||||
node,
|
||||
sweepName,
|
||||
faces,
|
||||
thickness,
|
||||
insertIndex,
|
||||
variableName,
|
||||
}: {
|
||||
node: Node<Program>
|
||||
sweepName: string
|
||||
faces: Expr[]
|
||||
thickness: Expr
|
||||
insertIndex?: number
|
||||
variableName?: string
|
||||
}): { modifiedAst: Node<Program>; pathToNode: PathToNode } {
|
||||
const modifiedAst = structuredClone(node)
|
||||
const name =
|
||||
variableName ?? findUniqueName(node, KCL_DEFAULT_CONSTANT_PREFIXES.SHELL)
|
||||
const shell = createCallExpressionStdLibKw(
|
||||
'shell',
|
||||
createIdentifier(sweepName),
|
||||
[
|
||||
createLabeledArg('faces', createArrayExpression(faces)),
|
||||
createLabeledArg('thickness', thickness),
|
||||
]
|
||||
)
|
||||
|
||||
const variable = createVariableDeclaration(name, shell)
|
||||
const insertAt =
|
||||
insertIndex !== undefined
|
||||
? insertIndex
|
||||
: modifiedAst.body.length
|
||||
? modifiedAst.body.length
|
||||
: 0
|
||||
|
||||
if (modifiedAst.body.length) {
|
||||
modifiedAst.body.splice(insertAt, 0, variable)
|
||||
} else {
|
||||
modifiedAst.body.push(variable)
|
||||
}
|
||||
|
||||
const argIndex = 0
|
||||
const pathToNode: PathToNode = [
|
||||
['body', ''],
|
||||
[insertAt, 'index'],
|
||||
['declaration', 'VariableDeclaration'],
|
||||
['init', 'VariableDeclarator'],
|
||||
['arguments', 'CallExpressionKw'],
|
||||
[argIndex, ARG_INDEX_FIELD],
|
||||
['arg', LABELED_ARG_FIELD],
|
||||
]
|
||||
|
||||
return {
|
||||
modifiedAst,
|
||||
pathToNode,
|
||||
}
|
||||
}
|
||||
|
||||
export function addSweep(
|
||||
node: Node<Program>,
|
||||
profileDeclarator: VariableDeclarator,
|
||||
|
Reference in New Issue
Block a user