@@ -5,7 +5,6 @@ import type { NonCodeMeta } from '@rust/kcl-lib/bindings/NonCodeMeta'
55
66import {
77 createArrayExpression ,
8- createCallExpressionStdLib ,
98 createCallExpressionStdLibKw ,
109 createExpressionStatement ,
1110 createIdentifier ,
@@ -14,7 +13,6 @@ import {
1413 createLabeledArg ,
1514 createLiteral ,
1615 createLocalName ,
17- createObjectExpression ,
1816 createPipeExpression ,
1917 createVariableDeclaration ,
2018 findUniqueName ,
@@ -439,9 +437,11 @@ export function loftSketches(
439437 const modifiedAst = structuredClone ( node )
440438 const name = findUniqueName ( node , KCL_DEFAULT_CONSTANT_PREFIXES . LOFT )
441439 const elements = declarators . map ( ( d ) => createLocalName ( d . id . name ) )
442- const loft = createCallExpressionStdLib ( 'loft' , [
440+ const loft = createCallExpressionStdLibKw (
441+ 'loft' ,
443442 createArrayExpression ( elements ) ,
444- ] )
443+ [ ]
444+ )
445445 const declaration = createVariableDeclaration ( name , loft )
446446 modifiedAst . body . push ( declaration )
447447 const pathToNode : PathToNode = [
@@ -574,101 +574,6 @@ export function addSweep({
574574 }
575575}
576576
577- export function revolveSketch (
578- node : Node < Program > ,
579- pathToNode : PathToNode ,
580- shouldPipe = false ,
581- angle : Expr = createLiteral ( 4 )
582- ) :
583- | {
584- modifiedAst : Node < Program >
585- pathToNode : PathToNode
586- pathToRevolveArg : PathToNode
587- }
588- | Error {
589- const _node = structuredClone ( node )
590- const _node1 = getNodeFromPath ( _node , pathToNode )
591- if ( err ( _node1 ) ) return _node1
592- const { node : sketchExpression } = _node1
593-
594- // determine if sketchExpression is in a pipeExpression or not
595- const _node2 = getNodeFromPath < PipeExpression > (
596- _node ,
597- pathToNode ,
598- 'PipeExpression'
599- )
600- if ( err ( _node2 ) ) return _node2
601- const { node : pipeExpression } = _node2
602-
603- const isInPipeExpression = pipeExpression . type === 'PipeExpression'
604-
605- const _node3 = getNodeFromPath < VariableDeclarator > (
606- _node ,
607- pathToNode ,
608- 'VariableDeclarator'
609- )
610- if ( err ( _node3 ) ) return _node3
611- const { node : variableDeclarator , shallowPath : pathToDecleration } = _node3
612-
613- const revolveCall = createCallExpressionStdLib ( 'revolve' , [
614- createObjectExpression ( {
615- angle : angle ,
616- // TODO: hard coded 'X' axis for revolve MVP, should be changed.
617- axis : createLocalName ( 'X' ) ,
618- } ) ,
619- createLocalName ( variableDeclarator . id . name ) ,
620- ] )
621-
622- if ( shouldPipe ) {
623- const pipeChain = createPipeExpression (
624- isInPipeExpression
625- ? [ ...pipeExpression . body , revolveCall ]
626- : [ sketchExpression as any , revolveCall ]
627- )
628-
629- variableDeclarator . init = pipeChain
630- const pathToRevolveArg : PathToNode = [
631- ...pathToDecleration ,
632- [ 'init' , 'VariableDeclarator' ] ,
633- [ 'body' , '' ] ,
634- [ pipeChain . body . length - 1 , 'index' ] ,
635- [ 'arguments' , 'CallExpression' ] ,
636- [ 0 , 'index' ] ,
637- ]
638-
639- return {
640- modifiedAst : _node ,
641- pathToNode,
642- pathToRevolveArg,
643- }
644- }
645-
646- // We're not creating a pipe expression,
647- // but rather a separate constant for the extrusion
648- const name = findUniqueName ( node , KCL_DEFAULT_CONSTANT_PREFIXES . REVOLVE )
649- const VariableDeclaration = createVariableDeclaration ( name , revolveCall )
650- const sketchIndexInPathToNode =
651- pathToDecleration . findIndex ( ( a ) => a [ 0 ] === 'body' ) + 1
652- const sketchIndexInBody = pathToDecleration [ sketchIndexInPathToNode ] [ 0 ]
653- if ( typeof sketchIndexInBody !== 'number' )
654- return new Error ( 'expected sketchIndexInBody to be a number' )
655- _node . body . splice ( sketchIndexInBody + 1 , 0 , VariableDeclaration )
656-
657- const pathToRevolveArg : PathToNode = [
658- [ 'body' , '' ] ,
659- [ sketchIndexInBody + 1 , 'index' ] ,
660- [ 'declaration' , 'VariableDeclaration' ] ,
661- [ 'init' , 'VariableDeclarator' ] ,
662- [ 'arguments' , 'CallExpression' ] ,
663- [ 0 , 'index' ] ,
664- ]
665- return {
666- modifiedAst : _node ,
667- pathToNode : [ ...pathToNode . slice ( 0 , - 1 ) , [ - 1 , 'index' ] ] ,
668- pathToRevolveArg,
669- }
670- }
671-
672577export function sketchOnExtrudedFace (
673578 node : Node < Program > ,
674579 sketchPathToNode : PathToNode ,
0 commit comments