From 4d7cac6c1de1caadcdd6aa9e2830ab78b7b1200a Mon Sep 17 00:00:00 2001 From: Jess Frazelle Date: Fri, 21 Jun 2024 21:57:51 -0700 Subject: [PATCH] add code mods for surfaces Signed-off-by: Jess Frazelle --- src/lang/modifyAst.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/lang/modifyAst.ts b/src/lang/modifyAst.ts index b442d45fb..4bc333ac2 100644 --- a/src/lang/modifyAst.ts +++ b/src/lang/modifyAst.ts @@ -394,9 +394,11 @@ export function sketchOnExtrudedFace( 'const' ) - console.log('sketchPathToNode', sketchPathToNode) - console.log('extrudePathToNode', extrudePathToNode) - _node.body = [..._node.body, newSurface] + const expressionIndex = Math.max( + sketchPathToNode[1][0] as number, + extrudePathToNode[1][0] as number + ) + _node.body.splice(expressionIndex + 1, 0, newSurface) // Create the variable for the sketch. const newSketchName = findUniqueName( @@ -407,8 +409,8 @@ export function sketchOnExtrudedFace( newSketchName, createIdentifier(newSurfaceName) ) - _node.body = [..._node.body, sketchVariableDeclaration] - const sketchIndex = _node.body.length - 1 + const sketchIndex = expressionIndex + 2 + _node.body.splice(sketchIndex, 0, sketchVariableDeclaration) let newPathToNode: PathToNode = [ ['body', ''],