diff --git a/e2e/playwright/sketch-tests.spec.ts b/e2e/playwright/sketch-tests.spec.ts index e688a59f0d..3f151d0415 100644 --- a/e2e/playwright/sketch-tests.spec.ts +++ b/e2e/playwright/sketch-tests.spec.ts @@ -40,7 +40,7 @@ test.describe('Sketch tests', () => { const screwRadius = 3 const wireRadius = 2 const wireOffset = 0.5 - + const screwHole = startSketchOn('XY') ${startProfileAt1} |> arc({ @@ -48,7 +48,7 @@ test.describe('Sketch tests', () => { angle_start: 0, angle_end: 360 }, %) - + const part001 = startSketchOn('XY') ${startProfileAt2} |> xLine(width * .5, %) @@ -57,7 +57,7 @@ test.describe('Sketch tests', () => { |> close(%) |> hole(screwHole, %) |> extrude(thickness, %) - + const part002 = startSketchOn('-XZ') ${startProfileAt3} |> xLine(width / 4, %) @@ -954,4 +954,68 @@ const sketch002 = startSketchOn(extrude001, 'END') await u.getGreatestPixDiff(XYPlanePoint, noPlanesColor) ).toBeLessThan(3) }) + + test('Can attempt to sketch on revolved face', async ({ + page, + browserName, + }) => { + test.skip( + browserName === 'webkit', + 'Skip on Safari until `window.tearDown` is working there' + ) + const u = await getUtils(page) + await page.setViewportSize({ width: 1200, height: 500 }) + + await page.addInitScript(async () => { + localStorage.setItem( + 'persistCode', + `const lugHeadLength = 0.25 + const lugDiameter = 0.5 + const lugLength = 2 + + fn lug = (origin, length, diameter, plane) => { + const lugSketch = startSketchOn(plane) + |> startProfileAt([origin[0] + lugDiameter / 2, origin[1]], %) + |> angledLineOfYLength({ angle: 60, length: lugHeadLength }, %) + |> xLineTo(0 + .001, %) + |> yLineTo(0, %) + |> close(%) + |> revolve({ axis: "Y" }, %) + + return lugSketch + } + + lug([0, 0], 10, .5, "XY")` + ) + }) + + await u.waitForAuthSkipAppStart() + + await u.openDebugPanel() + await u.expectCmdLog('[data-message-type="execution-done"]') + await u.closeDebugPanel() + + /*** + * Test Plan + * Start the sketch mode + * Click the middle of the screen which should click the top face that is revolved + * Wait till you see the line tool be enabled + * Wait till you see the exit sketch enabled + * + * This is supposed to test that you are allowed to go into sketch mode to sketch on a revolved face + */ + + await page.getByRole('button', { name: 'Start Sketch' }).click() + + await expect(async () => { + await page.mouse.click(600, 250) + await page.waitForTimeout(1000) + await expect( + page.getByRole('button', { name: 'Exit Sketch' }) + ).toBeVisible() + await expect( + page.getByRole('button', { name: 'line Line', exact: true }) + ).toHaveAttribute('aria-pressed', 'true') + }).toPass({ timeout: 40_000, intervals: [1_000] }) + }) }) diff --git a/src/hooks/useEngineConnectionSubscriptions.ts b/src/hooks/useEngineConnectionSubscriptions.ts index 57cd89d8d0..b542d93bfc 100644 --- a/src/hooks/useEngineConnectionSubscriptions.ts +++ b/src/hooks/useEngineConnectionSubscriptions.ts @@ -9,8 +9,8 @@ import { useModelingContext } from './useModelingContext' import { getEventForSelectWithPoint } from 'lib/selections' import { getCapCodeRef, - getExtrudeEdgeCodeRef, - getExtrusionFromSuspectedExtrudeSurface, + getSweepEdgeCodeRef, + getSweepFromSuspectedSweepSurface, getSolid2dCodeRef, getWallCodeRef, } from 'lang/std/artifactGraph' @@ -47,7 +47,7 @@ export function useEngineConnectionSubscriptions() { if (err(codeRef)) return editorManager.setHighlightRange([codeRef.range]) } else if (artifact?.type === 'wall') { - const extrusion = getExtrusionFromSuspectedExtrudeSurface( + const extrusion = getSweepFromSuspectedSweepSurface( data.entity_id, engineCommandManager.artifactGraph ) @@ -61,8 +61,8 @@ export function useEngineConnectionSubscriptions() { ? [codeRef.range] : [codeRef.range, extrusion.codeRef.range] ) - } else if (artifact?.type === 'extrudeEdge') { - const codeRef = getExtrudeEdgeCodeRef( + } else if (artifact?.type === 'sweepEdge') { + const codeRef = getSweepEdgeCodeRef( artifact, engineCommandManager.artifactGraph ) @@ -172,7 +172,7 @@ export function useEngineConnectionSubscriptions() { } const faceId = planeOrFaceId const artifact = engineCommandManager.artifactGraph.get(faceId) - const extrusion = getExtrusionFromSuspectedExtrudeSurface( + const extrusion = getSweepFromSuspectedSweepSurface( faceId, engineCommandManager.artifactGraph ) diff --git a/src/lang/modifyAst/addFillet.ts b/src/lang/modifyAst/addFillet.ts index 53b0980616..2f0218c84c 100644 --- a/src/lang/modifyAst/addFillet.ts +++ b/src/lang/modifyAst/addFillet.ts @@ -35,7 +35,7 @@ import { Selections, canFilletSelection } from 'lib/selections' import { KclCommandValue } from 'lib/commandTypes' import { ArtifactGraph, - getExtrusionFromSuspectedPath, + getSweepFromSuspectedPath, } from 'lang/std/artifactGraph' import { kclManager, engineCommandManager, editorManager } from 'lib/singletons' @@ -152,7 +152,7 @@ export function getPathToExtrudeForSegmentSelection( ) if (trap(sketchGroup)) return sketchGroup - const extrusion = getExtrusionFromSuspectedPath(sketchGroup.id, artifactGraph) + const extrusion = getSweepFromSuspectedPath(sketchGroup.id, artifactGraph) if (err(extrusion)) return extrusion const pathToExtrudeNode = getNodePathFromSourceRange( diff --git a/src/lang/std/__snapshots__/artifactGraph.test.ts.snap b/src/lang/std/__snapshots__/artifactGraph.test.ts.snap index e999ca576e..00e41a643c 100644 --- a/src/lang/std/__snapshots__/artifactGraph.test.ts.snap +++ b/src/lang/std/__snapshots__/artifactGraph.test.ts.snap @@ -33,7 +33,6 @@ Map { 70, ], }, - "extrusionId": "UUID", "planeId": "UUID", "segIds": [ "UUID", @@ -43,6 +42,7 @@ Map { "UUID", ], "solid2dId": "UUID", + "sweepId": "UUID", "type": "path", }, "UUID-2" => { @@ -175,6 +175,7 @@ Map { "UUID", ], "pathId": "UUID", + "subType": "extrusion", "surfaceIds": [ "UUID", "UUID", @@ -183,99 +184,99 @@ Map { "UUID", "UUID", ], - "type": "extrusion", + "type": "sweep", }, "UUID-9" => { "edgeCutEdgeIds": [], - "extrusionId": "UUID", "pathIds": [], "segId": "UUID", + "sweepId": "UUID", "type": "wall", }, "UUID-10" => { "edgeCutEdgeIds": [], - "extrusionId": "UUID", "pathIds": [ "UUID", ], "segId": "UUID", + "sweepId": "UUID", "type": "wall", }, "UUID-11" => { "edgeCutEdgeIds": [], - "extrusionId": "UUID", "pathIds": [], "segId": "UUID", + "sweepId": "UUID", "type": "wall", }, "UUID-12" => { "edgeCutEdgeIds": [], - "extrusionId": "UUID", "pathIds": [], "segId": "UUID", + "sweepId": "UUID", "type": "wall", }, "UUID-13" => { "edgeCutEdgeIds": [], - "extrusionId": "UUID", "pathIds": [], "subType": "start", + "sweepId": "UUID", "type": "cap", }, "UUID-14" => { "edgeCutEdgeIds": [], - "extrusionId": "UUID", "pathIds": [], "subType": "end", + "sweepId": "UUID", "type": "cap", }, "UUID-15" => { - "extrusionId": "UUID", "segId": "UUID", "subType": "opposite", - "type": "extrudeEdge", + "sweepId": "UUID", + "type": "sweepEdge", }, "UUID-16" => { - "extrusionId": "UUID", "segId": "UUID", "subType": "adjacent", - "type": "extrudeEdge", + "sweepId": "UUID", + "type": "sweepEdge", }, "UUID-17" => { - "extrusionId": "UUID", "segId": "UUID", "subType": "opposite", - "type": "extrudeEdge", + "sweepId": "UUID", + "type": "sweepEdge", }, "UUID-18" => { - "extrusionId": "UUID", "segId": "UUID", "subType": "adjacent", - "type": "extrudeEdge", + "sweepId": "UUID", + "type": "sweepEdge", }, "UUID-19" => { - "extrusionId": "UUID", "segId": "UUID", "subType": "opposite", - "type": "extrudeEdge", + "sweepId": "UUID", + "type": "sweepEdge", }, "UUID-20" => { - "extrusionId": "UUID", "segId": "UUID", "subType": "adjacent", - "type": "extrudeEdge", + "sweepId": "UUID", + "type": "sweepEdge", }, "UUID-21" => { - "extrusionId": "UUID", "segId": "UUID", "subType": "opposite", - "type": "extrudeEdge", + "sweepId": "UUID", + "type": "sweepEdge", }, "UUID-22" => { - "extrusionId": "UUID", "segId": "UUID", "subType": "adjacent", - "type": "extrudeEdge", + "sweepId": "UUID", + "type": "sweepEdge", }, "UUID-23" => { "codeRef": { @@ -308,7 +309,6 @@ Map { 395, ], }, - "extrusionId": "UUID", "planeId": "UUID", "segIds": [ "UUID", @@ -317,6 +317,7 @@ Map { "UUID", ], "solid2dId": "UUID", + "sweepId": "UUID", "type": "path", }, "UUID-25" => { @@ -425,6 +426,7 @@ Map { "UUID", ], "pathId": "UUID", + "subType": "extrusion", "surfaceIds": [ "UUID", "UUID", @@ -432,78 +434,78 @@ Map { "UUID", "UUID", ], - "type": "extrusion", + "type": "sweep", }, "UUID-31" => { "edgeCutEdgeIds": [], - "extrusionId": "UUID", "pathIds": [], "segId": "UUID", + "sweepId": "UUID", "type": "wall", }, "UUID-32" => { "edgeCutEdgeIds": [], - "extrusionId": "UUID", "pathIds": [], "segId": "UUID", + "sweepId": "UUID", "type": "wall", }, "UUID-33" => { "edgeCutEdgeIds": [], - "extrusionId": "UUID", "pathIds": [], "segId": "UUID", + "sweepId": "UUID", "type": "wall", }, "UUID-34" => { "edgeCutEdgeIds": [], - "extrusionId": "UUID", "pathIds": [], "subType": "start", + "sweepId": "UUID", "type": "cap", }, "UUID-35" => { "edgeCutEdgeIds": [], - "extrusionId": "UUID", "pathIds": [], "subType": "end", + "sweepId": "UUID", "type": "cap", }, "UUID-36" => { - "extrusionId": "UUID", "segId": "UUID", "subType": "opposite", - "type": "extrudeEdge", + "sweepId": "UUID", + "type": "sweepEdge", }, "UUID-37" => { - "extrusionId": "UUID", "segId": "UUID", "subType": "adjacent", - "type": "extrudeEdge", + "sweepId": "UUID", + "type": "sweepEdge", }, "UUID-38" => { - "extrusionId": "UUID", "segId": "UUID", "subType": "opposite", - "type": "extrudeEdge", + "sweepId": "UUID", + "type": "sweepEdge", }, "UUID-39" => { - "extrusionId": "UUID", "segId": "UUID", "subType": "adjacent", - "type": "extrudeEdge", + "sweepId": "UUID", + "type": "sweepEdge", }, "UUID-40" => { - "extrusionId": "UUID", "segId": "UUID", "subType": "opposite", - "type": "extrudeEdge", + "sweepId": "UUID", + "type": "sweepEdge", }, "UUID-41" => { - "extrusionId": "UUID", "segId": "UUID", "subType": "adjacent", - "type": "extrudeEdge", + "sweepId": "UUID", + "type": "sweepEdge", }, } `; diff --git a/src/lang/std/artifactGraph.test.ts b/src/lang/std/artifactGraph.test.ts index dbadeec327..c124699aeb 100644 --- a/src/lang/std/artifactGraph.test.ts +++ b/src/lang/std/artifactGraph.test.ts @@ -7,7 +7,7 @@ import { filterArtifacts, expandPlane, expandPath, - expandExtrusion, + expandSweep, ArtifactGraph, expandSegment, getArtifactsToUpdate, @@ -194,13 +194,13 @@ describe('testing createArtifactGraph', () => { }) it('there should be two extrusions, for the original and the sketchOnFace, the first extrusion should have 6 sides of the cube', () => { - const extrusions = [ - ...filterArtifacts({ types: ['extrusion'] }, theMap), - ].map((extrusion) => expandExtrusion(extrusion[1], theMap)) + const extrusions = [...filterArtifacts({ types: ['sweep'] }, theMap)].map( + (extrusion) => expandSweep(extrusion[1], theMap) + ) expect(extrusions).toHaveLength(2) extrusions.forEach((extrusion, index) => { if (err(extrusion)) throw extrusion - expect(extrusion.type).toBe('extrusion') + expect(extrusion.type).toBe('sweep') const firstExtrusionIsACubeIE6Sides = 6 const secondExtrusionIsATriangularPrismIE5Sides = 5 expect(extrusion.surfaces.length).toBe( @@ -535,7 +535,7 @@ describe('testing getArtifactsToUpdate', () => { type: 'path', segIds: [], planeId: 'UUID-1', - extrusionId: '', + sweepId: '', codeRef: { pathToNode: [['body', '']], range: [43, 70], @@ -544,7 +544,8 @@ describe('testing getArtifactsToUpdate', () => { ]) expect(getUpdateObjects('extrude')).toEqual([ { - type: 'extrusion', + type: 'sweep', + subType: 'extrusion', pathId: expect.any(String), surfaceIds: [], edgeIds: [], @@ -557,7 +558,7 @@ describe('testing getArtifactsToUpdate', () => { type: 'path', segIds: expect.any(Array), planeId: expect.any(String), - extrusionId: expect.any(String), + sweepId: expect.any(String), codeRef: { range: [43, 70], pathToNode: [['body', '']], @@ -580,7 +581,7 @@ describe('testing getArtifactsToUpdate', () => { type: 'path', segIds: expect.any(Array), planeId: expect.any(String), - extrusionId: expect.any(String), + sweepId: expect.any(String), codeRef: { range: [43, 70], pathToNode: [['body', '']], @@ -617,7 +618,7 @@ describe('testing getArtifactsToUpdate', () => { type: 'wall', segId: expect.any(String), edgeCutEdgeIds: [], - extrusionId: expect.any(String), + sweepId: expect.any(String), pathIds: [], }, { @@ -631,7 +632,8 @@ describe('testing getArtifactsToUpdate', () => { }, }, { - type: 'extrusion', + type: 'sweep', + subType: 'extrusion', pathId: expect.any(String), surfaceIds: expect.any(Array), edgeIds: expect.any(Array), @@ -644,7 +646,7 @@ describe('testing getArtifactsToUpdate', () => { type: 'wall', segId: expect.any(String), edgeCutEdgeIds: [], - extrusionId: expect.any(String), + sweepId: expect.any(String), pathIds: [], }, { @@ -658,7 +660,8 @@ describe('testing getArtifactsToUpdate', () => { }, }, { - type: 'extrusion', + type: 'sweep', + subType: 'extrusion', pathId: expect.any(String), surfaceIds: expect.any(Array), edgeIds: expect.any(Array), @@ -671,7 +674,7 @@ describe('testing getArtifactsToUpdate', () => { type: 'wall', segId: expect.any(String), edgeCutEdgeIds: [], - extrusionId: expect.any(String), + sweepId: expect.any(String), pathIds: [], }, { @@ -686,7 +689,8 @@ describe('testing getArtifactsToUpdate', () => { edgeCutId: expect.any(String), }, { - type: 'extrusion', + type: 'sweep', + subType: 'extrusion', pathId: expect.any(String), surfaceIds: expect.any(Array), edgeIds: expect.any(Array), @@ -699,7 +703,7 @@ describe('testing getArtifactsToUpdate', () => { type: 'wall', segId: expect.any(String), edgeCutEdgeIds: [], - extrusionId: expect.any(String), + sweepId: expect.any(String), pathIds: [], }, { @@ -713,7 +717,8 @@ describe('testing getArtifactsToUpdate', () => { }, }, { - type: 'extrusion', + type: 'sweep', + subType: 'extrusion', pathId: expect.any(String), surfaceIds: expect.any(Array), edgeIds: expect.any(Array), @@ -726,11 +731,12 @@ describe('testing getArtifactsToUpdate', () => { type: 'cap', subType: 'start', edgeCutEdgeIds: [], - extrusionId: expect.any(String), + sweepId: expect.any(String), pathIds: [], }, { - type: 'extrusion', + type: 'sweep', + subType: 'extrusion', pathId: expect.any(String), surfaceIds: expect.any(Array), edgeIds: expect.any(Array), @@ -743,11 +749,12 @@ describe('testing getArtifactsToUpdate', () => { type: 'cap', subType: 'end', edgeCutEdgeIds: [], - extrusionId: expect.any(String), + sweepId: expect.any(String), pathIds: [], }, { - type: 'extrusion', + type: 'sweep', + subType: 'extrusion', pathId: expect.any(String), surfaceIds: expect.any(Array), edgeIds: expect.any(Array), diff --git a/src/lang/std/artifactGraph.ts b/src/lang/std/artifactGraph.ts index cb688c4f22..0c2c27c100 100644 --- a/src/lang/std/artifactGraph.ts +++ b/src/lang/std/artifactGraph.ts @@ -25,7 +25,7 @@ export interface PathArtifact { type: 'path' planeId: ArtifactId segIds: Array - extrusionId: ArtifactId + sweepId: ArtifactId solid2dId?: ArtifactId codeRef: CommonCommandProperties } @@ -38,7 +38,7 @@ export interface PathArtifactRich { type: 'path' plane: PlaneArtifact | WallArtifact segments: Array - extrusion: ExtrusionArtifact + sweep: SweepArtifact codeRef: CommonCommandProperties } @@ -54,23 +54,26 @@ interface SegmentArtifactRich { type: 'segment' path: PathArtifact surf: WallArtifact - edges: Array + edges: Array edgeCut?: EdgeCut codeRef: CommonCommandProperties } -interface ExtrusionArtifact { - type: 'extrusion' - pathId: ArtifactId - surfaceIds: Array - edgeIds: Array +/** A Sweep is a more generic term for extrude, revolve, loft and sweep*/ +interface SweepArtifact { + type: 'sweep' + subType: 'extrusion' | 'revolve' + pathId: string + surfaceIds: Array + edgeIds: Array codeRef: CommonCommandProperties } -interface ExtrusionArtifactRich { - type: 'extrusion' +interface SweepArtifactRich { + type: 'sweep' + subType: 'extrusion' | 'revolve' path: PathArtifact surfaces: Array - edges: Array + edges: Array codeRef: CommonCommandProperties } @@ -78,21 +81,21 @@ interface WallArtifact { type: 'wall' segId: ArtifactId edgeCutEdgeIds: Array - extrusionId: ArtifactId + sweepId: ArtifactId pathIds: Array } interface CapArtifact { type: 'cap' subType: 'start' | 'end' edgeCutEdgeIds: Array - extrusionId: ArtifactId + sweepId: ArtifactId pathIds: Array } -interface ExtrudeEdge { - type: 'extrudeEdge' +interface SweepEdge { + type: 'sweepEdge' segId: ArtifactId - extrusionId: ArtifactId + sweepId: ArtifactId subType: 'opposite' | 'adjacent' } @@ -116,10 +119,10 @@ export type Artifact = | PlaneArtifact | PathArtifact | SegmentArtifact - | ExtrusionArtifact + | SweepArtifact | WallArtifact | CapArtifact - | ExtrudeEdge + | SweepEdge | EdgeCut | EdgeCutEdge | solid2D @@ -257,7 +260,7 @@ export function getArtifactsToUpdate({ type: 'wall', segId: existingPlane.segId, edgeCutEdgeIds: existingPlane.edgeCutEdgeIds, - extrusionId: existingPlane.extrusionId, + sweepId: existingPlane.sweepId, pathIds: existingPlane.pathIds, }, }, @@ -274,7 +277,7 @@ export function getArtifactsToUpdate({ type: 'path', segIds: [], planeId: currentPlaneId, - extrusionId: '', + sweepId: '', codeRef: { range, pathToNode }, }, }) @@ -294,7 +297,7 @@ export function getArtifactsToUpdate({ type: 'wall', segId: plane.segId, edgeCutEdgeIds: plane.edgeCutEdgeIds, - extrusionId: plane.extrusionId, + sweepId: plane.sweepId, pathIds: [id], }, }) @@ -337,11 +340,13 @@ export function getArtifactsToUpdate({ }) } return returnArr - } else if (cmd.type === 'extrude') { + } else if (cmd.type === 'extrude' || cmd.type === 'revolve') { + const subType = cmd.type === 'extrude' ? 'extrusion' : cmd.type returnArr.push({ id, artifact: { - type: 'extrusion', + type: 'sweep', + subType: subType, pathId: cmd.target, surfaceIds: [], edgeIds: [], @@ -352,7 +357,7 @@ export function getArtifactsToUpdate({ if (path?.type === 'path') returnArr.push({ id: cmd.target, - artifact: { ...path, extrusionId: id }, + artifact: { ...path, sweepId: id }, }) return returnArr } else if ( @@ -375,7 +380,7 @@ export function getArtifactsToUpdate({ type: 'wall', segId: curve_id, edgeCutEdgeIds: [], - extrusionId: path.extrusionId, + sweepId: path.sweepId, pathIds: [], }, }) @@ -383,12 +388,12 @@ export function getArtifactsToUpdate({ id: curve_id, artifact: { ...seg, surfaceId: face_id }, }) - const extrusion = getArtifact(path.extrusionId) - if (extrusion?.type === 'extrusion') { + const sweep = getArtifact(path.sweepId) + if (sweep?.type === 'sweep') { returnArr.push({ - id: path.extrusionId, + id: path.sweepId, artifact: { - ...extrusion, + ...sweep, surfaceIds: [face_id], }, }) @@ -407,16 +412,16 @@ export function getArtifactsToUpdate({ type: 'cap', subType: cap === 'bottom' ? 'start' : 'end', edgeCutEdgeIds: [], - extrusionId: path.extrusionId, + sweepId: path.sweepId, pathIds: [], }, }) - const extrusion = getArtifact(path.extrusionId) - if (extrusion?.type !== 'extrusion') return + const sweep = getArtifact(path.sweepId) + if (sweep?.type !== 'sweep') return returnArr.push({ - id: path.extrusionId, + id: path.sweepId, artifact: { - ...extrusion, + ...sweep, surfaceIds: [face_id], }, }) @@ -439,9 +444,9 @@ export function getArtifactsToUpdate({ ) { const wall = getArtifact(cmd.face_id) if (wall?.type !== 'wall') return returnArr - const extrusion = getArtifact(wall.extrusionId) - if (extrusion?.type !== 'extrusion') return returnArr - const path = getArtifact(extrusion.pathId) + const sweep = getArtifact(wall.sweepId) + if (sweep?.type !== 'sweep') return returnArr + const path = getArtifact(sweep.pathId) if (path?.type !== 'path') return returnArr const segment = getArtifact(cmd.edge_id) if (segment?.type !== 'segment') return returnArr @@ -450,13 +455,13 @@ export function getArtifactsToUpdate({ { id: response.data.modeling_response.data.edge, artifact: { - type: 'extrudeEdge', + type: 'sweepEdge', subType: cmd.type === 'solid3d_get_prev_adjacent_edge' ? 'adjacent' : 'opposite', segId: cmd.edge_id, - extrusionId: path.extrusionId, + sweepId: path.sweepId, }, }, { @@ -467,9 +472,9 @@ export function getArtifactsToUpdate({ }, }, { - id: path.extrusionId, + id: path.sweepId, artifact: { - ...extrusion, + ...sweep, edgeIds: [response.data.modeling_response.data.edge], }, }, @@ -582,10 +587,10 @@ export function expandPath( { keys: path.segIds, types: ['segment'] }, artifactGraph ) - const extrusion = getArtifactOfTypes( + const sweep = getArtifactOfTypes( { - key: path.extrusionId, - types: ['extrusion'], + key: path.sweepId, + types: ['sweep'], }, artifactGraph ) @@ -593,40 +598,41 @@ export function expandPath( { key: path.planeId, types: ['plane', 'wall'] }, artifactGraph ) - if (err(extrusion)) return extrusion + if (err(sweep)) return sweep if (err(plane)) return plane return { type: 'path', segments: Array.from(segs.values()), - extrusion, + sweep, plane, codeRef: path.codeRef, } } -export function expandExtrusion( - extrusion: ExtrusionArtifact, +export function expandSweep( + sweep: SweepArtifact, artifactGraph: ArtifactGraph -): ExtrusionArtifactRich | Error { +): SweepArtifactRich | Error { const surfs = getArtifactsOfTypes( - { keys: extrusion.surfaceIds, types: ['wall', 'cap'] }, + { keys: sweep.surfaceIds, types: ['wall', 'cap'] }, artifactGraph ) const edges = getArtifactsOfTypes( - { keys: extrusion.edgeIds, types: ['extrudeEdge'] }, + { keys: sweep.edgeIds, types: ['sweepEdge'] }, artifactGraph ) const path = getArtifactOfTypes( - { key: extrusion.pathId, types: ['path'] }, + { key: sweep.pathId, types: ['path'] }, artifactGraph ) if (err(path)) return path return { - type: 'extrusion', + type: 'sweep', + subType: 'extrusion', surfaces: Array.from(surfs.values()), edges: Array.from(edges.values()), path, - codeRef: extrusion.codeRef, + codeRef: sweep.codeRef, } } @@ -643,7 +649,7 @@ export function expandSegment( artifactGraph ) const edges = getArtifactsOfTypes( - { keys: segment.edgeIds, types: ['extrudeEdge'] }, + { keys: segment.edgeIds, types: ['sweepEdge'] }, artifactGraph ) const edgeCut = segment.edgeCutId @@ -670,13 +676,13 @@ export function getCapCodeRef( cap: CapArtifact, artifactGraph: ArtifactGraph ): CommonCommandProperties | Error { - const extrusion = getArtifactOfTypes( - { key: cap.extrusionId, types: ['extrusion'] }, + const sweep = getArtifactOfTypes( + { key: cap.sweepId, types: ['sweep'] }, artifactGraph ) - if (err(extrusion)) return extrusion + if (err(sweep)) return sweep const path = getArtifactOfTypes( - { key: extrusion.pathId, types: ['path'] }, + { key: sweep.pathId, types: ['path'] }, artifactGraph ) if (err(path)) return path @@ -707,8 +713,8 @@ export function getWallCodeRef( return seg.codeRef } -export function getExtrudeEdgeCodeRef( - edge: ExtrudeEdge, +export function getSweepEdgeCodeRef( + edge: SweepEdge, artifactGraph: ArtifactGraph ): CommonCommandProperties | Error { const seg = getArtifactOfTypes( @@ -719,29 +725,29 @@ export function getExtrudeEdgeCodeRef( return seg.codeRef } -export function getExtrusionFromSuspectedExtrudeSurface( +export function getSweepFromSuspectedSweepSurface( id: ArtifactId, artifactGraph: ArtifactGraph -): ExtrusionArtifact | Error { +): SweepArtifact | Error { const artifact = getArtifactOfTypes( { key: id, types: ['wall', 'cap'] }, artifactGraph ) if (err(artifact)) return artifact return getArtifactOfTypes( - { key: artifact.extrusionId, types: ['extrusion'] }, + { key: artifact.sweepId, types: ['sweep'] }, artifactGraph ) } -export function getExtrusionFromSuspectedPath( +export function getSweepFromSuspectedPath( id: ArtifactId, artifactGraph: ArtifactGraph -): ExtrusionArtifact | Error { +): SweepArtifact | Error { const path = getArtifactOfTypes({ key: id, types: ['path'] }, artifactGraph) if (err(path)) return path return getArtifactOfTypes( - { key: path.extrusionId, types: ['extrusion'] }, + { key: path.sweepId, types: ['sweep'] }, artifactGraph ) } diff --git a/src/lang/std/artifactMapGraphs/exampleCode1.png b/src/lang/std/artifactMapGraphs/exampleCode1.png index b2d076f2db..c56d2030f6 100644 Binary files a/src/lang/std/artifactMapGraphs/exampleCode1.png and b/src/lang/std/artifactMapGraphs/exampleCode1.png differ diff --git a/src/lang/std/artifactMapGraphs/sketchOnFaceOnFaceEtc.png b/src/lang/std/artifactMapGraphs/sketchOnFaceOnFaceEtc.png index aac95b160f..4a18696a8d 100644 Binary files a/src/lang/std/artifactMapGraphs/sketchOnFaceOnFaceEtc.png and b/src/lang/std/artifactMapGraphs/sketchOnFaceOnFaceEtc.png differ diff --git a/src/lib/selections.ts b/src/lib/selections.ts index 2801cd28a3..dff6bfa9ea 100644 --- a/src/lib/selections.ts +++ b/src/lib/selections.ts @@ -31,7 +31,7 @@ import { getArtifactOfTypes, getArtifactsOfTypes, getCapCodeRef, - getExtrudeEdgeCodeRef, + getSweepEdgeCodeRef, getSolid2dCodeRef, getWallCodeRef, } from 'lang/std/artifactGraph' @@ -141,8 +141,8 @@ export async function getEventForSelectWithPoint({ }, } } - if (_artifact.type === 'extrudeEdge') { - const codeRef = getExtrudeEdgeCodeRef( + if (_artifact.type === 'sweepEdge') { + const codeRef = getSweepEdgeCodeRef( _artifact, engineCommandManager.artifactGraph ) @@ -575,12 +575,10 @@ function codeToIdSelections( } if (type === 'edge' && entry.artifact.type === 'segment') { const edges = getArtifactsOfTypes( - { keys: entry.artifact.edgeIds, types: ['extrudeEdge'] }, + { keys: entry.artifact.edgeIds, types: ['sweepEdge'] }, engineCommandManager.artifactGraph ) - const edge = [...edges].find( - ([_, edge]) => edge.type === 'extrudeEdge' - ) + const edge = [...edges].find(([_, edge]) => edge.type === 'sweepEdge') if (!edge) return bestCandidate = { artifact: edge[1], @@ -590,12 +588,12 @@ function codeToIdSelections( } if (type === 'adjacent-edge' && entry.artifact.type === 'segment') { const edges = getArtifactsOfTypes( - { keys: entry.artifact.edgeIds, types: ['extrudeEdge'] }, + { keys: entry.artifact.edgeIds, types: ['sweepEdge'] }, engineCommandManager.artifactGraph ) const edge = [...edges].find( ([_, edge]) => - edge.type === 'extrudeEdge' && edge.subType === 'adjacent' + edge.type === 'sweepEdge' && edge.subType === 'adjacent' ) if (!edge) return bestCandidate = { @@ -610,8 +608,8 @@ function codeToIdSelections( ) { const extrusion = getArtifactOfTypes( { - key: entry.artifact.extrusionId, - types: ['extrusion'], + key: entry.artifact.sweepId, + types: ['sweep'], }, engineCommandManager.artifactGraph )