diff --git a/src/components/ModelingMachineProvider.tsx b/src/components/ModelingMachineProvider.tsx index 8282e3fbf..5e3c3d86a 100644 --- a/src/components/ModelingMachineProvider.tsx +++ b/src/components/ModelingMachineProvider.tsx @@ -572,8 +572,6 @@ export const ModelingMachineProvider = ({ }, 'has valid loft selection': ({ context: { selectionRanges } }) => { console.log('selectionRanges', selectionRanges) - // A user can begin lofting if they either have 2+ faces selected or nothing selected - // TODO: this is a dummy copy from the sweep one const hasNoSelection = selectionRanges.graphSelections.length === 0 || isRangeBetweenCharacters(selectionRanges) || @@ -582,14 +580,16 @@ export const ModelingMachineProvider = ({ if (hasNoSelection) { // they have no selection, we should enable the button // so they can select the faces through the cmdbar - // BUT only if there's extrudable geometry - return doesSceneHaveSweepableSketch(kclManager.ast) + // BUT only if there's two extrudable geometry + const count = 2 + return doesSceneHaveSweepableSketch(kclManager.ast, count) } - // TODO: check if we need a check like this for loft + console.log( 'isSketchPipe(selectionRanges)', isSketchPipe(selectionRanges) ) + // TODO: The way this is isn't letting me loft // if (!isSketchPipe(selectionRanges)) return false const canLoft = canLoftSelection(selectionRanges) diff --git a/src/lang/queryAst.ts b/src/lang/queryAst.ts index 85360c4f1..9a48e6878 100644 --- a/src/lang/queryAst.ts +++ b/src/lang/queryAst.ts @@ -988,7 +988,7 @@ export function hasSketchPipeBeenExtruded(selection: Selection, ast: Program) { } /** File must contain at least one sketch that has not been extruded already */ -export function doesSceneHaveSweepableSketch(ast: Node) { +export function doesSceneHaveSweepableSketch(ast: Node, count = 1) { const theMap: any = {} traverse(ast as any, { enter(node) { @@ -1037,7 +1037,7 @@ export function doesSceneHaveSweepableSketch(ast: Node) { } }, }) - return Object.keys(theMap).length > 0 + return Object.keys(theMap).length >= count } export function getObjExprProperty( diff --git a/src/lib/selections.ts b/src/lib/selections.ts index e8aa37505..0b1a78923 100644 --- a/src/lib/selections.ts +++ b/src/lib/selections.ts @@ -565,6 +565,7 @@ export function canLoftSelection(selection: Selections) { buildCommonNodeFromSelection(selection, i) ) console.log('commonNodes', commonNodes) + console.log('isSketchPipe', isSketchPipe(selection)) return ( // TODO: check if we need ifSketchPipe or other things enabled // !!isSketchPipe(selection) && diff --git a/src/machines/modelingMachine.ts b/src/machines/modelingMachine.ts index d2d0db061..ab2e71ea0 100644 --- a/src/machines/modelingMachine.ts +++ b/src/machines/modelingMachine.ts @@ -714,7 +714,6 @@ export const modelingMachine = setup({ if (!event.data) return const { selection } = event.data let ast = kclManager.ast - // TODO: make it all list based const nodePaths = selection.graphSelections.map((s) => getNodePathFromSourceRange(ast, s?.codeRef.range) )