Point-and-click Sweep (first PR) (#4989)
* Refactor 'Delete selection' as actor
Will fix #4662
* WIP logging
* WIP: working Solid3dGetExtrusionFaceInfo for loft
* Working wall deletion of loft
* Add offset plane deletion
* Add feature tree deletion of shell
* Clean up
* Revert "Clean up"
This reverts commit 214763cc2b
.
* Clean up rust changes, taking the sketch with the most paths
* Working cap selection and deletion
* Clean up
* Add test for loft and offset plane deletion via selection
* A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-16-cores)
* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-macos-8-cores)
* Set reenter: false as it was originally
* Passing test
* Add shell deletion via feature tree test
* Revert the migration to promise actor
* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)
* Trigger CI
* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)
* Trigger CI
* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)
* Trigger CI
* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)
* Trigger CI
* Use cmd.id as solid_id after latest engine merge
* Add feature tree deletion of offset plane and fix lint
* Add feature tree deletion of loft
* Clean up
* Better comment
* Lint fix
* Remove sketch sorting
* WIP: sweep point-and-click
* Working sweep
* Add test
* Make sweep a development command
* Fix tsc error
* Clean up for review
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
@ -45,6 +45,7 @@ import {
|
||||
import { revolveSketch } from 'lang/modifyAst/addRevolve'
|
||||
import {
|
||||
addOffsetPlane,
|
||||
addSweep,
|
||||
deleteFromSelection,
|
||||
extrudeSketch,
|
||||
loftSketches,
|
||||
@ -266,6 +267,7 @@ export type ModelingMachineEvent =
|
||||
| { type: 'Export'; data: ModelingCommandSchema['Export'] }
|
||||
| { type: 'Make'; data: ModelingCommandSchema['Make'] }
|
||||
| { type: 'Extrude'; data?: ModelingCommandSchema['Extrude'] }
|
||||
| { type: 'Sweep'; data?: ModelingCommandSchema['Sweep'] }
|
||||
| { type: 'Loft'; data?: ModelingCommandSchema['Loft'] }
|
||||
| { type: 'Shell'; data?: ModelingCommandSchema['Shell'] }
|
||||
| { type: 'Revolve'; data?: ModelingCommandSchema['Revolve'] }
|
||||
@ -1544,6 +1546,66 @@ export const modelingMachine = setup({
|
||||
}
|
||||
}
|
||||
),
|
||||
sweepAstMod: fromPromise(
|
||||
async ({
|
||||
input,
|
||||
}: {
|
||||
input: ModelingCommandSchema['Sweep'] | undefined
|
||||
}) => {
|
||||
if (!input) return new Error('No input provided')
|
||||
// Extract inputs
|
||||
const ast = kclManager.ast
|
||||
const { profile, path } = input
|
||||
|
||||
// Find the profile declaration
|
||||
const profileNodePath = getNodePathFromSourceRange(
|
||||
ast,
|
||||
profile.graphSelections[0].codeRef.range
|
||||
)
|
||||
const profileNode = getNodeFromPath<VariableDeclarator>(
|
||||
ast,
|
||||
profileNodePath,
|
||||
'VariableDeclarator'
|
||||
)
|
||||
if (err(profileNode)) {
|
||||
return new Error("Couldn't parse profile selection")
|
||||
}
|
||||
const profileDeclarator = profileNode.node
|
||||
|
||||
// Find the path declaration
|
||||
const pathNodePath = getNodePathFromSourceRange(
|
||||
ast,
|
||||
path.graphSelections[0].codeRef.range
|
||||
)
|
||||
const pathNode = getNodeFromPath<VariableDeclarator>(
|
||||
ast,
|
||||
pathNodePath,
|
||||
'VariableDeclarator'
|
||||
)
|
||||
if (err(pathNode)) {
|
||||
return new Error("Couldn't parse path selection")
|
||||
}
|
||||
const pathDeclarator = pathNode.node
|
||||
|
||||
// Perform the sweep
|
||||
const sweepRes = addSweep(ast, profileDeclarator, pathDeclarator)
|
||||
const updateAstResult = await kclManager.updateAst(
|
||||
sweepRes.modifiedAst,
|
||||
true,
|
||||
{
|
||||
focusPath: [sweepRes.pathToNode],
|
||||
}
|
||||
)
|
||||
|
||||
await codeManager.updateEditorWithAstAndWriteToFile(
|
||||
updateAstResult.newAst
|
||||
)
|
||||
|
||||
if (updateAstResult?.selections) {
|
||||
editorManager.selectRange(updateAstResult?.selections)
|
||||
}
|
||||
}
|
||||
),
|
||||
loftAstMod: fromPromise(
|
||||
async ({
|
||||
input,
|
||||
@ -1739,6 +1801,11 @@ export const modelingMachine = setup({
|
||||
reenter: false,
|
||||
},
|
||||
|
||||
Sweep: {
|
||||
target: 'Applying sweep',
|
||||
reenter: true,
|
||||
},
|
||||
|
||||
Loft: {
|
||||
target: 'Applying loft',
|
||||
reenter: true,
|
||||
@ -2531,6 +2598,19 @@ export const modelingMachine = setup({
|
||||
},
|
||||
},
|
||||
|
||||
'Applying sweep': {
|
||||
invoke: {
|
||||
src: 'sweepAstMod',
|
||||
id: 'sweepAstMod',
|
||||
input: ({ event }) => {
|
||||
if (event.type !== 'Sweep') return undefined
|
||||
return event.data
|
||||
},
|
||||
onDone: ['idle'],
|
||||
onError: ['idle'],
|
||||
},
|
||||
},
|
||||
|
||||
'Applying loft': {
|
||||
invoke: {
|
||||
src: 'loftAstMod',
|
||||
|
Reference in New Issue
Block a user