From 40c77d4b5a8276606e0ec2fb152f21342ec3788b Mon Sep 17 00:00:00 2001 From: max-mrgrsk <156543465+max-mrgrsk@users.noreply.github.com> Date: Sat, 14 Sep 2024 19:41:33 +0200 Subject: [PATCH 1/2] fix isSketchPipe in canExtrudeSelectionItem --- src/lib/selections.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lib/selections.ts b/src/lib/selections.ts index c85f36c0bc..8eec2b641e 100644 --- a/src/lib/selections.ts +++ b/src/lib/selections.ts @@ -433,10 +433,14 @@ export function canFilletSelection(selection: Selections) { } function canExtrudeSelectionItem(selection: Selections, i: number) { + const isolatedSelection = { + ...selection, + codeBasedSelections: [selection.codeBasedSelections[i]], + } const commonNode = buildCommonNodeFromSelection(selection, i) return ( - !!isSketchPipe(selection) && + !!isSketchPipe(isolatedSelection) && nodeHasClose(commonNode) && !nodeHasExtrude(commonNode) ) From 434a8dec3450e87cc368551ddfd71235619d3bac Mon Sep 17 00:00:00 2001 From: max-mrgrsk <156543465+max-mrgrsk@users.noreply.github.com> Date: Sat, 14 Sep 2024 19:42:41 +0200 Subject: [PATCH 2/2] fix count in getSelectionType used to count only same type as first selection --- src/lib/selections.ts | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/src/lib/selections.ts b/src/lib/selections.ts index 8eec2b641e..aee8e39e6e 100644 --- a/src/lib/selections.ts +++ b/src/lib/selections.ts @@ -459,25 +459,17 @@ export type ResolvedSelectionType = [Selection['type'] | 'other', number] export function getSelectionType( selection: Selections ): ResolvedSelectionType[] { - return selection.codeBasedSelections - .map((s, i) => { - if (canExtrudeSelectionItem(selection, i)) { - return ['extrude-wall', 1] as ResolvedSelectionType // This is implicitly determining what a face is, which is bad - } else { - return ['other', 1] as ResolvedSelectionType - } - }) - .reduce((acc, [type, count]) => { - const foundIndex = acc.findIndex((item) => item && item[0] === type) - - if (foundIndex === -1) { - return [...acc, [type, count]] - } else { - const temp = [...acc] - temp[foundIndex][1] += count - return temp - } - }, [] as ResolvedSelectionType[]) + const extrudableCount = selection.codeBasedSelections.filter((_, i) => { + const singleSelection = { + ...selection, + codeBasedSelections: [selection.codeBasedSelections[i]], + } + return canExtrudeSelectionItem(singleSelection, 0) + }).length + + return extrudableCount === selection.codeBasedSelections.length + ? [['extrude-wall', extrudableCount]] + : [['other', selection.codeBasedSelections.length]] } export function getSelectionTypeDisplayText(