Merge remote-tracking branch 'origin' into kurt-multi-profile-again

This commit is contained in:
Kurt Hutten Irev-Dev
2025-02-11 07:25:52 +11:00
20 changed files with 1219 additions and 17 deletions

View File

@ -56,6 +56,7 @@ export function revolveSketch(
if (err(sketchNode)) return sketchNode
let generatedAxis
let axisDeclaration: PathToNode | null = null
if (axisOrEdge === 'Edge') {
const pathToAxisSelection = getNodePathFromSourceRange(
@ -80,6 +81,13 @@ export function revolveSketch(
const axisSelection = edge?.graphSelections[0]?.artifact
if (!axisSelection) return new Error('Generated axis selection is missing.')
generatedAxis = getEdgeTagCall(tag, axisSelection)
if (
axisSelection.type === 'segment' ||
axisSelection.type === 'path' ||
axisSelection.type === 'edgeCut'
) {
axisDeclaration = axisSelection.codeRef.pathToNode
}
} else {
generatedAxis = createLiteral(axis)
}
@ -108,11 +116,28 @@ export function revolveSketch(
const VariableDeclaration = createVariableDeclaration(name, revolveCall)
const lastSketchNodePath =
orderedSketchNodePaths[orderedSketchNodePaths.length - 1]
const sketchIndexInBody = Number(lastSketchNodePath[1][0])
let sketchIndexInBody = Number(lastSketchNodePath[1][0])
if (typeof sketchIndexInBody !== 'number')
return new Error('expected sketchIndexInBody to be a number')
clonedAst.body.splice(sketchIndexInBody + 1, 0, VariableDeclaration)
if (typeof sketchIndexInBody !== 'number')
return new Error('expected insertIndex to be a number')
// If an axis was selected in KCL, find the max index to insert the revolve command
if (axisDeclaration) {
const axisIndexInPathToNode =
axisDeclaration.findIndex((a) => a[0] === 'body') + 1
const axisIndex = axisDeclaration[axisIndexInPathToNode][0]
if (typeof axisIndex !== 'number')
return new Error('expected axisIndex to be a number')
sketchIndexInBody = Math.max(sketchIndexInBody, axisIndex)
}
clonedAst.body.splice(sketchIndexInBody + 1, 0, VariableDeclaration)
const pathToRevolveArg: PathToNode = [
['body', ''],
[sketchIndexInBody + 1, 'index'],
@ -121,6 +146,7 @@ export function revolveSketch(
['arguments', 'CallExpression'],
[0, 'index'],
]
return {
modifiedAst: clonedAst,
pathToSketchNode: [...pathToSketchNode.slice(0, -1), [-1, 'index']],