WIP selections

This commit is contained in:
Pierre Jacquier
2024-11-29 11:17:31 -05:00
parent e984b20664
commit a7d3552472
4 changed files with 8 additions and 8 deletions

View File

@ -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)

View File

@ -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<Program>) {
export function doesSceneHaveSweepableSketch(ast: Node<Program>, count = 1) {
const theMap: any = {}
traverse(ast as any, {
enter(node) {
@ -1037,7 +1037,7 @@ export function doesSceneHaveSweepableSketch(ast: Node<Program>) {
}
},
})
return Object.keys(theMap).length > 0
return Object.keys(theMap).length >= count
}
export function getObjExprProperty(

View File

@ -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) &&

View File

@ -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)
)