-
Notifications
You must be signed in to change notification settings - Fork 84
Allow point-and-click Offset Plane to work from sweep faces #7882
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
adc34d9
d82569a
7421d57
d90ac82
4526094
a618e47
a8846b9
48ba38a
8b8320e
67f9765
040e4d1
5c5245c
a3073b3
e13f1f4
4c5b54a
522e159
dddefda
a58a1b5
2485166
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -912,18 +912,10 @@ openSketch = startSketchOn(XY) | |
toolbar, | ||
cmdBar, | ||
}) => { | ||
// One dumb hardcoded screen pixel value | ||
const testPoint = { x: 700, y: 200 } | ||
// TODO: replace the testPoint selection with a feature tree click once that's supported #7544 | ||
const [clickOnXzPlane] = scene.makeMouseHelpers(testPoint.x, testPoint.y) | ||
const expectedOutput = `plane001 = offsetPlane(XZ, offset = 5)` | ||
|
||
await homePage.goToModelingScene() | ||
await scene.settled(cmdBar) | ||
|
||
await test.step(`Look for the blue of the XZ plane`, async () => { | ||
//await scene.expectPixelColor([50, 51, 96], testPoint, 15) // FIXME | ||
}) | ||
await test.step(`Go through the command bar flow`, async () => { | ||
await toolbar.offsetPlaneButton.click() | ||
await expect | ||
|
@@ -933,30 +925,30 @@ openSketch = startSketchOn(XY) | |
stage: 'arguments', | ||
currentArgKey: 'plane', | ||
currentArgValue: '', | ||
headerArguments: { Plane: '', Distance: '' }, | ||
headerArguments: { Plane: '', Offset: '' }, | ||
highlightedHeaderArg: 'plane', | ||
commandName: 'Offset plane', | ||
}) | ||
await clickOnXzPlane() | ||
const xz = await toolbar.getFeatureTreeOperation('Front plane', 0) | ||
await xz.click() | ||
Comment on lines
+932
to
+933
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And would like to keep these two tests as they aren't px dependent anymore |
||
await cmdBar.expectState({ | ||
stage: 'arguments', | ||
currentArgKey: 'distance', | ||
currentArgKey: 'offset', | ||
currentArgValue: '5', | ||
headerArguments: { Plane: '1 plane', Distance: '' }, | ||
highlightedHeaderArg: 'distance', | ||
headerArguments: { Plane: '1 plane', Offset: '' }, | ||
highlightedHeaderArg: 'offset', | ||
commandName: 'Offset plane', | ||
}) | ||
await cmdBar.progressCmdBar() | ||
}) | ||
|
||
await test.step(`Confirm code is added to the editor, scene has changed`, async () => { | ||
await test.step(`Confirm code is added to the editor`, async () => { | ||
await editor.expectEditor.toContain(expectedOutput) | ||
await editor.expectState({ | ||
diagnostics: [], | ||
activeLines: [expectedOutput], | ||
highlightedCode: '', | ||
}) | ||
await scene.expectPixelColor([74, 74, 74], testPoint, 15) | ||
}) | ||
|
||
await test.step('Delete offset plane via feature tree selection', async () => { | ||
|
@@ -967,7 +959,6 @@ openSketch = startSketchOn(XY) | |
) | ||
await operationButton.click({ button: 'left' }) | ||
await page.keyboard.press('Delete') | ||
//await scene.expectPixelColor([50, 51, 96], testPoint, 15) // FIXME | ||
}) | ||
}) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
import type { BodyItem } from '@rust/kcl-lib/bindings/BodyItem' | ||
import type { Name } from '@rust/kcl-lib/bindings/Name' | ||
import type { Node } from '@rust/kcl-lib/bindings/Node' | ||
import type { NonCodeMeta } from '@rust/kcl-lib/bindings/NonCodeMeta' | ||
|
||
|
@@ -27,11 +26,7 @@ import { | |
isNodeSafeToReplace, | ||
isNodeSafeToReplacePath, | ||
} from '@src/lang/queryAst' | ||
import { | ||
ARG_INDEX_FIELD, | ||
LABELED_ARG_FIELD, | ||
UNLABELED_ARG, | ||
} from '@src/lang/queryAstConstants' | ||
import { ARG_INDEX_FIELD, LABELED_ARG_FIELD } from '@src/lang/queryAstConstants' | ||
import { getNodePathFromSourceRange } from '@src/lang/queryAstNodePathUtils' | ||
import { | ||
addTagForSketchOnFace, | ||
|
@@ -422,56 +417,6 @@ export function sketchOnExtrudedFace( | |
} | ||
} | ||
|
||
/** | ||
* Append an offset plane to the AST | ||
*/ | ||
export function addOffsetPlane({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moved to |
||
node, | ||
plane, | ||
insertIndex, | ||
offset, | ||
planeName, | ||
}: { | ||
node: Node<Program> | ||
plane: Node<Literal> | Node<Name> // Can be DefaultPlaneStr or string for offsetPlanes | ||
insertIndex?: number | ||
offset: Expr | ||
planeName?: string | ||
}): { modifiedAst: Node<Program>; pathToNode: PathToNode } { | ||
const modifiedAst = structuredClone(node) | ||
const newPlaneName = | ||
planeName ?? findUniqueName(node, KCL_DEFAULT_CONSTANT_PREFIXES.PLANE) | ||
|
||
const newPlane = createVariableDeclaration( | ||
newPlaneName, | ||
createCallExpressionStdLibKw('offsetPlane', plane, [ | ||
createLabeledArg('offset', offset), | ||
]) | ||
) | ||
|
||
const insertAt = | ||
insertIndex !== undefined | ||
? insertIndex | ||
: modifiedAst.body.length | ||
? modifiedAst.body.length | ||
: 0 | ||
|
||
modifiedAst.body.length | ||
? modifiedAst.body.splice(insertAt, 0, newPlane) | ||
: modifiedAst.body.push(newPlane) | ||
const pathToNode: PathToNode = [ | ||
['body', ''], | ||
[insertAt, 'index'], | ||
['declaration', 'VariableDeclaration'], | ||
['init', 'VariableDeclarator'], | ||
['unlabeled', UNLABELED_ARG], | ||
] | ||
return { | ||
modifiedAst, | ||
pathToNode, | ||
} | ||
} | ||
|
||
/** | ||
* Add an import call to load a part | ||
*/ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed this to be more in line with KCL