@@ -1016,8 +1016,62 @@ sketch002 = sketch(on = XZ) {
10161016 `region001 = region(point = [1mm, 1mm], sketch = s)
10171017sweep001 = sweep(region001, path = sketch002.line1)`
10181018 )
1019- // TODO: enable once KCL is updated
1020- // await runNewAstAndCheckForSweep(result.modifiedAst, rustContextInThisFile)
1019+ await runNewAstAndCheckForSweep ( result . modifiedAst , rustContextInThisFile )
1020+ } )
1021+
1022+ it ( 'should add a sweep call from region001 with sketch solve line and arc path segments' , async ( ) => {
1023+ const code = `@settings(experimentalFeatures = allow)
1024+
1025+ sketch001 = sketch(on = XY) {
1026+ circle1 = circle(start = [var -2.38mm, var 2.51mm], center = [var 0mm, var 0mm])
1027+ coincident([circle1.center, ORIGIN])
1028+ }
1029+ sketch002 = sketch(on = YZ) {
1030+ line1 = line(start = [var 0mm, var 0mm], end = [var 0mm, var 10mm])
1031+ coincident([line1.start, ORIGIN])
1032+ arc1 = arc(start = [var 6.66mm, var 22.81mm], end = [var 0mm, var 10mm], center = [var 15.65mm, var 10mm])
1033+ coincident([line1.end, arc1.end])
1034+ tangent([line1, arc1])
1035+ vertical(line1)
1036+ verticalDistance([line1.start, line1.end]) == 10
1037+ }
1038+ region001 = region(point = [2.3783mm, -2.5082mm], sketch = sketch001)
1039+ region002 = region(point = [2.3783mm, -2.5082mm], sketch = sketch001)`
1040+ const { ast, artifactGraph } = await getAstAndArtifactGraphEngineless (
1041+ code ,
1042+ instanceInThisFile ,
1043+ rustContextInThisFile
1044+ )
1045+
1046+ const regionArtifacts = [ ...artifactGraph . values ( ) ]
1047+ . filter ( ( artifact ) => artifact . type === 'path' )
1048+ . slice ( - 2 , - 1 )
1049+ expect ( regionArtifacts ) . toHaveLength ( 1 )
1050+ const sketches = createSelectionFromArtifacts (
1051+ regionArtifacts ,
1052+ artifactGraph
1053+ )
1054+
1055+ const pathArtifacts = [ ...artifactGraph . values ( ) ]
1056+ . filter ( ( artifact ) => artifact . type === 'segment' )
1057+ . slice ( - 2 )
1058+ expect ( pathArtifacts ) . toHaveLength ( 2 )
1059+ const path = createSelectionFromArtifacts ( pathArtifacts , artifactGraph )
1060+
1061+ const result = addSweep ( {
1062+ ast,
1063+ artifactGraph,
1064+ sketches,
1065+ path,
1066+ wasmInstance : instanceInThisFile ,
1067+ } )
1068+ if ( err ( result ) ) throw result
1069+
1070+ const newCode = recast ( result . modifiedAst , instanceInThisFile )
1071+ expect ( newCode ) . toContain (
1072+ `sweep001 = sweep(region001, path = [sketch002.line1, sketch002.arc1])`
1073+ )
1074+ await runNewAstAndCheckForSweep ( result . modifiedAst , rustContextInThisFile )
10211075 } )
10221076
10231077 it ( 'should edit a sweep call from a sketch region selection' , async ( ) => {
0 commit comments