WIP mutliple faces
This commit is contained in:
@ -813,6 +813,7 @@ shellPointAndClickCapCases.forEach(({ shouldPreselect }) => {
|
||||
})
|
||||
await clickOnCap()
|
||||
await cmdBar.progressCmdBar()
|
||||
await cmdBar.progressCmdBar()
|
||||
await cmdBar.expectState({
|
||||
stage: 'review',
|
||||
headerArguments: {
|
||||
@ -831,6 +832,7 @@ shellPointAndClickCapCases.forEach(({ shouldPreselect }) => {
|
||||
await test.step(`Go through the command bar flow with preselected sketches`, async () => {
|
||||
await toolbar.shellButton.click()
|
||||
await cmdBar.progressCmdBar()
|
||||
await cmdBar.progressCmdBar()
|
||||
await cmdBar.expectState({
|
||||
stage: 'review',
|
||||
headerArguments: {
|
||||
@ -900,6 +902,7 @@ extrude001 = extrude(40, sketch001)
|
||||
})
|
||||
await clickOnWall()
|
||||
await cmdBar.progressCmdBar()
|
||||
await cmdBar.progressCmdBar()
|
||||
await cmdBar.expectState({
|
||||
stage: 'review',
|
||||
headerArguments: {
|
||||
|
@ -618,21 +618,6 @@ export function addShell({
|
||||
}): Error | { modifiedAst: Node<Program>; pathToNode: PathToNode } {
|
||||
const modifiedAst = structuredClone(node)
|
||||
|
||||
const graphSelection = selection.graphSelections[0]
|
||||
if (!(graphSelection && graphSelection instanceof Object)) {
|
||||
return Error('No plane selected')
|
||||
}
|
||||
|
||||
// Get the sketch ref from the selection
|
||||
const sketchNode = getNodeFromPath<VariableDeclarator>(
|
||||
modifiedAst,
|
||||
graphSelection.codeRef.pathToNode,
|
||||
'VariableDeclarator'
|
||||
)
|
||||
if (err(sketchNode)) {
|
||||
return sketchNode
|
||||
}
|
||||
|
||||
// Look up the corresponding extrude
|
||||
const clonedAstForGetExtrude = structuredClone(modifiedAst)
|
||||
const extrudeLookupResult = getPathToExtrudeForSegmentSelection(
|
||||
@ -653,29 +638,45 @@ export function addShell({
|
||||
return extrudeNode
|
||||
}
|
||||
|
||||
const selectedArtifact = graphSelection.artifact
|
||||
if (!selectedArtifact || !selectedArtifact) {
|
||||
return new Error('Bad artifact')
|
||||
}
|
||||
|
||||
// Check on the selection, and handle the wall vs cap casees
|
||||
let expr: Expr
|
||||
if (selectedArtifact.type === 'cap') {
|
||||
expr = createLiteral(selectedArtifact.subType)
|
||||
} else {
|
||||
const tagResult = mutateAstWithTagForSketchSegment(
|
||||
const expressions: Expr[] = []
|
||||
for (const graphSelection of selection.graphSelections) {
|
||||
// Get the sketch ref from the selection
|
||||
const sketchNode = getNodeFromPath<VariableDeclarator>(
|
||||
modifiedAst,
|
||||
extrudeLookupResult.pathToSegmentNode
|
||||
graphSelection.codeRef.pathToNode,
|
||||
'VariableDeclarator'
|
||||
)
|
||||
if (err(tagResult)) return tagResult
|
||||
const { tag } = tagResult
|
||||
expr = createIdentifier(tag)
|
||||
if (err(sketchNode)) {
|
||||
return sketchNode
|
||||
}
|
||||
|
||||
const selectedArtifact = graphSelection.artifact
|
||||
if (!selectedArtifact || !selectedArtifact) {
|
||||
return new Error('Bad artifact')
|
||||
}
|
||||
|
||||
// Check on the selection, and handle the wall vs cap casees
|
||||
let expr: Expr
|
||||
if (selectedArtifact.type === 'cap') {
|
||||
expr = createLiteral(selectedArtifact.subType)
|
||||
} else if (selectedArtifact.type === 'wall') {
|
||||
const tagResult = mutateAstWithTagForSketchSegment(
|
||||
modifiedAst,
|
||||
extrudeLookupResult.pathToSegmentNode
|
||||
)
|
||||
if (err(tagResult)) return tagResult
|
||||
const { tag } = tagResult
|
||||
expr = createIdentifier(tag)
|
||||
} else {
|
||||
continue
|
||||
}
|
||||
expressions.push(expr)
|
||||
}
|
||||
|
||||
const name = findUniqueName(node, KCL_DEFAULT_CONSTANT_PREFIXES.SHELL)
|
||||
const shell = createCallExpressionStdLib('shell', [
|
||||
createObjectExpression({
|
||||
faces: createArrayExpression([expr]),
|
||||
faces: createArrayExpression(expressions),
|
||||
thickness,
|
||||
}),
|
||||
createIdentifier(extrudeNode.node.id.name),
|
||||
|
@ -289,10 +289,9 @@ export const modelingMachineCommandConfig: StateMachineCommandSetConfig<
|
||||
selection: {
|
||||
inputType: 'selection',
|
||||
selectionTypes: ['cap', 'wall'],
|
||||
// TODO: allow multiple faces to be selected here
|
||||
multiple: false,
|
||||
multiple: true,
|
||||
required: true,
|
||||
skip: true,
|
||||
skip: false,
|
||||
},
|
||||
thickness: {
|
||||
inputType: 'kcl',
|
||||
|
Reference in New Issue
Block a user