#7408 Can not pick sketch plane using the feature tree and related improvements (#7609)

* Add ability to pick default plane in feature tree in 'Sketch no face' mode

* add ability to select deoffset plane where starting a new sketch

* use selectDefaultSketchPlane

* refactor: remove some duplication

* warning cleanups

* feature tree items selectable depedngin on no face sketch mode

* lint

* fix small jump because of border:none when going into and back from 'No face sketch' mode

* grey out items other than offset planes in 'No face sketch' mode

* start sketching on plane in context menu

* sketch on offset plane with context menu

* add ability to right click on default plane and start sketch on it

* default planes in feature tree should be selectable because of right click context menu

* add right click Start sketch option for selected plane on the canvas

* selectDefaultSketchPlane returns error now

* circular deps

* move select functions to lib/selections.ts to avoid circular deps

* add test for clicking on feature tree after starting a new sketch

* graphite suggestion

* fix bug of not being able to create offset plane using another offset plane with command bar

* add ability to select default plane on feature when going through the Offset plane command bar flow
This commit is contained in:
Andrew Varga
2025-07-04 19:14:12 +02:00
committed by GitHub
parent 01230b0aa1
commit 5f7a75a327
7 changed files with 442 additions and 150 deletions

View File

@ -2609,15 +2609,15 @@ export const modelingMachine = setup({
insertIndex = nodeToEdit[1][0]
}
// Extract the default plane from selection
const plane = selection.otherSelections[0]
if (!(plane && plane instanceof Object && 'name' in plane))
const selectedPlane = getSelectedPlane(selection)
if (!selectedPlane) {
return trap('No plane selected')
}
// Get the default plane name from the selection
const offsetPlaneResult = addOffsetPlane({
node: ast,
defaultPlane: plane.name,
plane: selectedPlane,
offset:
'variableName' in distance
? distance.variableIdentifierAst
@ -5520,6 +5520,33 @@ export function isEditingExistingSketch({
return (hasStartProfileAt && maybePipeExpression.body.length > 1) || hasCircle
}
const getSelectedPlane = (
selection: Selections
): Node<Name> | Node<Literal> | undefined => {
const defaultPlane = selection.otherSelections[0]
if (
defaultPlane &&
defaultPlane instanceof Object &&
'name' in defaultPlane
) {
return createLiteral(defaultPlane.name.toUpperCase())
}
const offsetPlane = selection.graphSelections[0]
if (offsetPlane.artifact?.type === 'plane') {
const artifactId = offsetPlane.artifact?.id
const variableName = Object.entries(kclManager.variables).find(
([_, value]) => {
return value?.type === 'Plane' && value.value?.artifactId === artifactId
}
)
const offsetPlaneName = variableName?.[0]
return offsetPlaneName ? createLocalName(offsetPlaneName) : undefined
}
return undefined
}
export function pipeHasCircle({
sketchDetails,
}: {